diff --git a/src/gtp_vty.c b/src/gtp_vty.c index 3c1c318..c611f1b 100644 --- a/src/gtp_vty.c +++ b/src/gtp_vty.c @@ -548,9 +548,9 @@ DEFUN(request_channel, /* * Show */ -DEFUN(show_gtp_fwd, - show_gtp_fwd_cmd, - "show gtp fwd", +DEFUN(show_xdp_forwarding, + show_xdp_forwarding_cmd, + "show xdp forwarding", SHOW_STR "XDP GTP Fowarding Dataplane ruleset\n") { @@ -572,9 +572,9 @@ DEFUN(show_gtp_fwd, return CMD_SUCCESS; } -DEFUN(show_xdp_fwd_iptnl, - show_xdp_fwd_iptnl_cmd, - "show xdp fwd iptunnel", +DEFUN(show_xdp_forwarding_iptnl, + show_xdp_forwarding_iptnl_cmd, + "show xdp forwarding iptunnel", SHOW_STR "GTP XDP Forwarding IPIP Tunnel ruleset\n") { @@ -596,9 +596,9 @@ DEFUN(show_xdp_fwd_iptnl, return CMD_SUCCESS; } -DEFUN(show_gtp_rt, - show_gtp_rt_cmd, - "show gtp rt", +DEFUN(show_xdp_routing, + show_xdp_routing_cmd, + "show xdp routing", SHOW_STR "GTP XDP Routing Dataplane ruleset\n") { @@ -620,9 +620,9 @@ DEFUN(show_gtp_rt, return CMD_SUCCESS; } -DEFUN(show_xdp_rt_iptnl, - show_xdp_rt_iptnl_cmd, - "show xdp rt iptunnel", +DEFUN(show_xdp_routing_iptnl, + show_xdp_routing_iptnl_cmd, + "show xdp routing iptunnel", SHOW_STR "GTP XDP Routing IPIP Tunnel ruleset\n") { @@ -891,17 +891,17 @@ gtp_vty_init(void) install_element(PDN_NODE, &request_channel_cmd); /* Install show commands */ - install_element(VIEW_NODE, &show_gtp_fwd_cmd); - install_element(VIEW_NODE, &show_xdp_fwd_iptnl_cmd); - install_element(VIEW_NODE, &show_gtp_rt_cmd); - install_element(VIEW_NODE, &show_xdp_rt_iptnl_cmd); + install_element(VIEW_NODE, &show_xdp_forwarding_cmd); + install_element(VIEW_NODE, &show_xdp_forwarding_iptnl_cmd); + install_element(VIEW_NODE, &show_xdp_routing_cmd); + install_element(VIEW_NODE, &show_xdp_routing_iptnl_cmd); install_element(VIEW_NODE, &show_xdp_mirror_cmd); install_element(VIEW_NODE, >p_send_echo_request_standard_cmd); install_element(VIEW_NODE, >p_send_echo_request_extended_cmd); - install_element(ENABLE_NODE, &show_gtp_fwd_cmd); - install_element(ENABLE_NODE, &show_xdp_fwd_iptnl_cmd); - install_element(ENABLE_NODE, &show_gtp_rt_cmd); - install_element(ENABLE_NODE, &show_xdp_rt_iptnl_cmd); + install_element(ENABLE_NODE, &show_xdp_forwarding_cmd); + install_element(ENABLE_NODE, &show_xdp_forwarding_iptnl_cmd); + install_element(ENABLE_NODE, &show_xdp_routing_cmd); + install_element(ENABLE_NODE, &show_xdp_routing_iptnl_cmd); install_element(ENABLE_NODE, &show_xdp_mirror_cmd); install_element(ENABLE_NODE, >p_send_echo_request_standard_cmd); install_element(ENABLE_NODE, >p_send_echo_request_extended_cmd); diff --git a/src/gtp_xdp_fwd.c b/src/gtp_xdp_fwd.c index 5830fb4..a101a07 100644 --- a/src/gtp_xdp_fwd.c +++ b/src/gtp_xdp_fwd.c @@ -123,12 +123,6 @@ gtp_xdp_teid_action(struct bpf_map *map, int action, gtp_teid_t *t) uint32_t key; size_t sz; - /* If daemon is currently stopping, we simply skip action on ruleset. - * This reduce daemon exit time and entries are properly released during - * kernel BPF map release. */ - if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) - return 0; - if (!t) return -1; @@ -247,6 +241,12 @@ gtp_xdp_fwd_teid_action(int action, gtp_teid_t *t) { gtp_bpf_opts_t *bpf_opts = &daemon_data->xdp_gtpu; + /* If daemon is currently stopping, we simply skip action on ruleset. + * This reduce daemon exit time and entries are properly released during + * kernel BPF map release. */ + if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) + return 0; + if (!__test_bit(GTP_FL_GTPU_LOADED_BIT, &daemon_data->flags)) return -1; @@ -287,6 +287,12 @@ gtp_xdp_fwd_iptnl_action(int action, gtp_iptnl_t *t) { gtp_bpf_opts_t *bpf_opts = &daemon_data->xdp_gtpu; + /* If daemon is currently stopping, we simply skip action on ruleset. + * This reduce daemon exit time and entries are properly released during + * kernel BPF map release. */ + if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) + return 0; + if (!__test_bit(GTP_FL_GTPU_LOADED_BIT, &daemon_data->flags)) return -1; diff --git a/src/gtp_xdp_ppp.c b/src/gtp_xdp_ppp.c index 3b03102..1f2a45d 100644 --- a/src/gtp_xdp_ppp.c +++ b/src/gtp_xdp_ppp.c @@ -124,12 +124,6 @@ gtp_xdp_ppp_map_action(struct bpf_map *map, int action, gtp_teid_t *t) struct ppp_key ppp_k; size_t sz; - /* If daemon is currently stopping, we simply skip action on ruleset. - * This reduce daemon exit time and entries are properly released during - * kernel BPF map release. */ - if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) - return 0; - if (__test_bit(GTP_TEID_FL_EGRESS, &t->flags)) gtp_xdp_rt_key_set(t, &rt_k); else @@ -249,10 +243,9 @@ gtp_xdp_teid_vty(struct bpf_map *map, vty_t *vty, gtp_teid_t *t) bytes += r[i].bytes; } - vty_out(vty, "| 0x%.8x | %.2x:%.2x:%.2x:%.2x:%.2x:%.2x| %9s | %12ld | %19ld |%s" + vty_out(vty, "| 0x%.8x | " ETHER_FMT "| %9s | %12ld | %19ld |%s" , ntohl(r[0].teid) - , r[0].h_dst[0], r[0].h_dst[1], r[0].h_dst[2] - , r[0].h_dst[3], r[0].h_dst[4], r[0].h_dst[5] + , ETHER_BYTES(r[0].h_dst) , "ingress" , packets, bytes , VTY_NEWLINE); @@ -266,6 +259,12 @@ int gtp_xdp_ppp_action(int action, gtp_teid_t *t, struct bpf_map *map_ingress, struct bpf_map *map_egress) { + /* If daemon is currently stopping, we simply skip action on ruleset. + * This reduce daemon exit time and entries are properly released during + * kernel BPF map release. */ + if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) + return 0; + if (__test_bit(GTP_TEID_FL_EGRESS, &t->flags)) return gtp_xdp_ppp_map_action(map_egress, action, t); @@ -276,6 +275,14 @@ int gtp_xdp_ppp_teid_vty(vty_t *vty, gtp_teid_t *t, struct bpf_map *map_ingress, struct bpf_map *map_egress) { + int err = 0; + + if (!t) { + err = (map_ingress) ? gtp_xdp_teid_vty(map_ingress, vty, NULL) : 0; + err = (err) ? : (map_egress) ? gtp_xdp_teid_vty(map_egress, vty, NULL) : 0; + return err; + } + if (__test_bit(GTP_TEID_FL_EGRESS, &t->flags)) return gtp_xdp_teid_vty(map_egress, vty, t); diff --git a/src/gtp_xdp_rt.c b/src/gtp_xdp_rt.c index ecdec65..2e15480 100644 --- a/src/gtp_xdp_rt.c +++ b/src/gtp_xdp_rt.c @@ -176,12 +176,6 @@ gtp_xdp_rt_action(struct bpf_map *map, int action, gtp_teid_t *t) struct ip_rt_key rt_key; size_t sz; - /* If daemon is currently stopping, we simply skip action on ruleset. - * This reduce daemon exit time and entries are properly released during - * kernel BPF map release. */ - if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) - return 0; - gtp_xdp_rt_key_set(t, &rt_key); /* Set rule */ @@ -306,6 +300,12 @@ gtp_xdp_rt_teid_action(int action, gtp_teid_t *t) gtp_apn_t *apn; int direction; + /* If daemon is currently stopping, we simply skip action on ruleset. + * This reduce daemon exit time and entries are properly released during + * kernel BPF map release. */ + if (__test_bit(GTP_FL_STOP_BIT, &daemon_data->flags)) + return 0; + if (!__test_bit(GTP_FL_GTP_ROUTE_LOADED_BIT, &daemon_data->flags) || !t) return -1; @@ -360,7 +360,7 @@ gtp_xdp_rt_vty(vty_t *vty) , VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); gtp_xdp_teid_vty(bpf_opts->bpf_maps[XDP_RT_MAP_TEID_INGRESS].map, vty, NULL); gtp_xdp_teid_vty(bpf_opts->bpf_maps[XDP_RT_MAP_TEID_EGRESS].map, vty, NULL); - gtp_xdp_teid_vty(bpf_opts->bpf_maps[XDP_RT_MAP_PPP_INGRESS].map, vty, NULL); + gtp_xdp_ppp_teid_vty(vty, NULL, bpf_opts->bpf_maps[XDP_RT_MAP_PPP_INGRESS].map, NULL); vty_out(vty, "+------------+------------------+-----------+--------------+---------------------+%s" , VTY_NEWLINE); return 0;