summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/reass
diff options
context:
space:
mode:
authorDamjan Marion <dmarion@me.com>2022-09-14 16:00:09 +0200
committerOle Tr�an <otroan@employees.org>2022-09-14 15:13:21 +0000
commit121a16af699b168daa712f58521275127f8eb29b (patch)
tree837d0a922268ace5b45461e84fbadc87a77a62cd /src/vnet/ip/reass
parentd7c030d6065962b433416c679f3b568b096b49e2 (diff)
ip: show fib index in ip4 reassembly trace
Type: improvement Change-Id: I371237803e2c3cb0e1b42b94f422867465e2bff6 Signed-off-by: Damjan Marion <dmarion@me.com>
Diffstat (limited to 'src/vnet/ip/reass')
-rw-r--r--src/vnet/ip/reass/ip4_full_reass.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c
index 3183560cc86..5b69234e438 100644
--- a/src/vnet/ip/reass/ip4_full_reass.c
+++ b/src/vnet/ip/reass/ip4_full_reass.c
@@ -73,21 +73,19 @@ typedef enum
typedef struct
{
- union
+ struct
{
- struct
- {
- u32 xx_id;
- ip4_address_t src;
- ip4_address_t dst;
- u16 frag_id;
- u8 proto;
- u8 unused;
- };
- u64 as_u64[2];
+ u16 frag_id;
+ u8 proto;
+ u8 unused;
+ u32 fib_index;
+ ip4_address_t src;
+ ip4_address_t dst;
};
} ip4_full_reass_key_t;
+STATIC_ASSERT_SIZEOF (ip4_full_reass_key_t, 16);
+
typedef union
{
struct
@@ -417,9 +415,8 @@ ip4_full_reass_free (ip4_full_reass_main_t * rm,
ip4_full_reass_per_thread_t * rt,
ip4_full_reass_t * reass)
{
- clib_bihash_kv_16_8_t kv;
- kv.key[0] = reass->key.as_u64[0];
- kv.key[1] = reass->key.as_u64[1];
+ clib_bihash_kv_16_8_t kv = {};
+ clib_memcpy_fast (&kv, &reass->key, sizeof (kv.key));
clib_bihash_add_del_16_8 (&rm->hash, &kv, 0);
return ip4_full_reass_free_ctx (rt, reass);
}
@@ -621,8 +618,7 @@ again:
++rt->reass_n;
}
- reass->key.as_u64[0] = kv->kv.key[0];
- reass->key.as_u64[1] = kv->kv.key[1];
+ clib_memcpy_fast (&reass->key, &kv->kv.key, sizeof (reass->key));
kv->v.reass_index = (reass - rt->pool);
kv->v.memory_owner_thread_index = vm->thread_index;
reass->last_heard = now;
@@ -1250,16 +1246,18 @@ ip4_full_reass_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
error0 = IP4_ERROR_REASS_MALFORMED_PACKET;
goto packet_enqueue;
}
- ip4_full_reass_kv_t kv;
- u8 do_handoff = 0;
- kv.k.as_u64[0] =
- (u64) vec_elt (ip4_main.fib_index_by_sw_if_index,
- vnet_buffer (b0)->sw_if_index[VLIB_RX]) |
- (u64) ip0->src_address.as_u32 << 32;
- kv.k.as_u64[1] =
- (u64) ip0->dst_address.
- as_u32 | (u64) ip0->fragment_id << 32 | (u64) ip0->protocol << 48;
+ u32 fib_index = vec_elt (ip4_main.fib_index_by_sw_if_index,
+ vnet_buffer (b0)->sw_if_index[VLIB_RX]);
+
+ ip4_full_reass_kv_t kv = { .k.fib_index = fib_index,
+ .k.src.as_u32 = ip0->src_address.as_u32,
+ .k.dst.as_u32 = ip0->dst_address.as_u32,
+ .k.frag_id = ip0->fragment_id,
+ .k.proto = ip0->protocol
+
+ };
+ u8 do_handoff = 0;
ip4_full_reass_t *reass = ip4_full_reass_find_or_create (
vm, node, rm, rt, &kv, &do_handoff, &n_left_to_next, &to_next);
@@ -1768,9 +1766,8 @@ format_ip4_full_reass_key (u8 * s, va_list * args)
{
ip4_full_reass_key_t *key = va_arg (*args, ip4_full_reass_key_t *);
s =
- format (s,
- "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
- key->xx_id, format_ip4_address, &key->src, format_ip4_address,
+ format (s, "fib_index: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
+ key->fib_index, format_ip4_address, &key->src, format_ip4_address,
&key->dst, clib_net_to_host_u16 (key->frag_id), key->proto);
return s;
}
/* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/* 
 *------------------------------------------------------------------
 * Copyright (c) 2005-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "g2.h"
#include "props.h"
#include <pwd.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <vppinfra/mem.h>

/*
 * globals
 */

GtkWidget *g_mainwindow;        /* The main window */

/* Graphical object heirarchy
 *
 * [main window]
 *   [main vbox]
 *     [main (e.g. file) menubar]
 *     [view hbox] 
 *     [view bottom menu]
 */

GtkWidget *g_mainvbox;
GtkWidget *g_mainhbox;

gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
    /* Allow window to be destroyed */
    return(FALSE);
}

void destroy(GtkWidget *widget, gpointer data)
{
    gtk_main_quit();
}

int main (int argc, char **argv)
{
    char tmpbuf [128];
    struct passwd *pw;
    char *event_file = 0;
    char *cpel_file = 0;
    char *clib_file =0;
    char *title = "none";
    int curarg=1;
    char *homedir;
    
    clib_mem_init (0, ((uword)3<<30));

    gtk_init(&argc, &argv);

    homedir = getenv ("HOME");
    tmpbuf[0] = 0;

    if (homedir) {
        sprintf(tmpbuf, "%s/.g2", homedir);
    } else {
        pw = getpwuid(geteuid());
        if (pw) {
            sprintf(tmpbuf, "%s/.g2", pw->pw_dir);
        }
    }
    if (tmpbuf[0])
        readprops(tmpbuf);

    g_mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_signal_connect (GTK_OBJECT(g_mainwindow), "delete_event",
                        GTK_SIGNAL_FUNC (delete_event), NULL);

    gtk_signal_connect (GTK_OBJECT(g_mainwindow), "destroy",
                        GTK_SIGNAL_FUNC (destroy), NULL);

    gtk_container_set_border_width(GTK_CONTAINER(g_mainwindow), 5);

    g_mainvbox = gtk_vbox_new(FALSE, 0);
    g_mainhbox = gtk_hbox_new(FALSE, 0);

    /* 
     * init routines
     */

    menu1_init();
    point_selector_init();
    view1_init();
    event_init();

    /* 
     * Now that we're ready to rock 'n roll, see if we've been asked to
     * press a few buttons...
     */
    
    while (curarg < argc) {
        if (!strncmp(argv[curarg], "--cpel-input", 4)) {
            curarg++;
            if (curarg < argc) {
                cpel_file = argv[curarg];
                curarg++;
                break;
            }
            g_error("Missing filename after --cpel-input");
        }
        if (!strncmp(argv[curarg], "--clib-input", 4)) {
            curarg++;
            if (curarg < argc) {
                clib_file = argv[curarg];
                curarg++;
                break;
            }
            g_error("Missing filename after --cpel-input");
        }

        if (!strncmp(argv[curarg], "--pointdefs", 3)) {
            curarg++;
            if (curarg < argc) {
                read_event_definitions(argv[curarg]);
                curarg++;
                continue;
            }
            g_error ("Missing filename after --pointdefs\n");
        }
        if (!strncmp(argv[curarg], "--event-log", 3)) {
            curarg++;
            if (curarg < argc) {
                event_file = argv[curarg];
                curarg++;
                continue;
            }
            g_error ("Missing filename after --event-log\n");
        }

        if (!strncmp(argv[curarg], "--ticks-per-us", 3)) {
            curarg++;
            if (curarg < argc) {
                ticks_per_ns = 0.0;
                ticks_per_ns = atof(argv[curarg]);
                if (ticks_per_ns == 0.0) {
                    g_error("ticks-per-ns (%s) didn't convert properly\n",
                            argv[curarg]);
                }
                ticks_per_ns_set = TRUE;
                curarg++;
                continue;
            }
            g_error ("Missing filename after --event-log\n");
        }

        fprintf(stderr, 
                "g2 [--pointdefs <filename>] [--event-log <filename>]\n");
        fprintf(stderr, "   [--ticks-per-us <value>]\n");
        fprintf(stderr, 
                "   [--cpel-input <filename>] [--clib-input <filename]>\n");
        fprintf(stderr, 
                "%s\n%s\n", version_string, minor_v_string);
        exit(0);
    }

    if (clib_file) {
        read_clib_file (clib_file);
        title = clib_file;
    } else if (cpel_file) {
        read_cpel_file(cpel_file);
        title = cpel_file;
    } else if (event_file) {
        read_events(event_file);
        title = event_file;
    }

    set_window_title(title);

    gtk_signal_connect (GTK_OBJECT (g_mainwindow), "key_press_event",
                        (GtkSignalFunc) view1_handle_key_press_event, NULL);
    gtk_container_add(GTK_CONTAINER(g_mainvbox), g_mainhbox);
    gtk_widget_show(g_mainhbox);
    gtk_container_add(GTK_CONTAINER(g_mainwindow), g_mainvbox);
    gtk_widget_show(g_mainvbox);
    gtk_widget_show(g_mainwindow);

    gtk_main();
    return(0);
}