From 5a46d676ef9623305f277ab4f841f2623ca8fd7b Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Tue, 20 Feb 2024 02:33:01 +0100 Subject: [PATCH 1/2] Add EOF Dummy commit for EOF --- src/gtp_xdp_iptnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gtp_xdp_iptnl.c b/src/gtp_xdp_iptnl.c index 19245d3..2a09a8c 100644 --- a/src/gtp_xdp_iptnl.c +++ b/src/gtp_xdp_iptnl.c @@ -197,4 +197,4 @@ gtp_xdp_iptnl_vty(vty_t *vty, struct bpf_map *map) , VTY_NEWLINE); free(r); return 0; -} \ No newline at end of file +} From 620d454bdda78882fd36a8faf838adebdcf1fff0 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Tue, 20 Feb 2024 02:33:34 +0100 Subject: [PATCH 2/2] VLAN: add for show and support no vlan Per the BPF program gtp_fwd.bpf encap VLAN is optional. If 0, it means no VLAN header. So let's support the same from the CLI. For debugging, let's dump all the content of the BPF map. TODO: write terminal keep dumping 1 single gtpu-ipip tunnel for the latest traffic-selector. Since the map could have many traffic-selector, the write terminal should vty_out all the entries. re-issuing the same CLI gtpu-ipip traffic-select N command does lead to an error since it is processed as an ADD rule instead of an UPDATE rule. add `no gtpu-ipip traffic-selector` in order to drop some. --- src/gtp_switch_vty.c | 18 +++++++++++------- src/gtp_xdp_iptnl.c | 12 +++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/gtp_switch_vty.c b/src/gtp_switch_vty.c index a7fd9cd..bd25da1 100644 --- a/src/gtp_switch_vty.c +++ b/src/gtp_switch_vty.c @@ -213,7 +213,7 @@ DEFUN(gtpc_force_pgw_selection, DEFUN(gtpu_ipip, gtpu_ipip_cmd, - "gtpu-ipip traffic-selector (A.B.C.D|X:X:X:X) local (A.B.C.D|X:X:X:X) remote (A.B.C.D|X:X:X:X) vlan <1-4095>", + "gtpu-ipip traffic-selector (A.B.C.D|X:X:X:X) local (A.B.C.D|X:X:X:X) remote (A.B.C.D|X:X:X:X) [vlan <1-4095>]", "GTP Userplane IPIP tunnel\n" "GTP-U local L3 destination address\n" "IPv4 Address\n" @@ -260,8 +260,8 @@ DEFUN(gtpu_ipip, return CMD_WARNING; } - if (argc == 4) { - VTY_GET_INTEGER_RANGE("Vlan ID", vlan, argv[3], 1, 4095); + if (argc == 5) { + VTY_GET_INTEGER_RANGE("Vlan ID", vlan, argv[4], 1, 4095); if (vlan) {} ; /* dummy test */ } @@ -513,12 +513,16 @@ gtp_config_write(vty_t *vty) vty_out(vty, " pgw-force-selection %s%s" , inet_sockaddrtos(&ctx->pgw_addr) , VTY_NEWLINE); - if (__test_bit(GTP_FL_IPTNL_BIT, &ctx->flags)) - vty_out(vty, " gtpu-ipip traffic-selector %u.%u.%u.%u local %u.%u.%u.%u remote %u.%u.%u.%u%s" + if (__test_bit(GTP_FL_IPTNL_BIT, &ctx->flags)) { + vty_out(vty, " gtpu-ipip traffic-selector %u.%u.%u.%u local %u.%u.%u.%u remote %u.%u.%u.%u" , NIPQUAD(ctx->iptnl.selector_addr) , NIPQUAD(ctx->iptnl.local_addr) - , NIPQUAD(ctx->iptnl.remote_addr) - , VTY_NEWLINE); + , NIPQUAD(ctx->iptnl.remote_addr)); + if (ctx->iptnl.encap_vlan_id) + vty_out(vty, " vlan %u" + , ctx->iptnl.encap_vlan_id); + vty_out(vty, "%s", VTY_NEWLINE); + } if (ctx->iptnl.flags & IPTNL_FL_TRANSPARENT_INGRESS_ENCAP) vty_out(vty, " gtpu-ipip transparent-ingress-encap%s", VTY_NEWLINE); if (ctx->iptnl.flags & IPTNL_FL_TRANSPARENT_EGRESS_ENCAP) diff --git a/src/gtp_xdp_iptnl.c b/src/gtp_xdp_iptnl.c index 2a09a8c..0b777ac 100644 --- a/src/gtp_xdp_iptnl.c +++ b/src/gtp_xdp_iptnl.c @@ -169,9 +169,9 @@ gtp_xdp_iptnl_vty(vty_t *vty, struct bpf_map *map) return -1; } - vty_out(vty, "+------------------+------------------+------------------+-------+%s" - "| Selector Address | Local Address | Remote Address | Flags |%s" - "+------------------+------------------+------------------+-------+%s" + vty_out(vty, "+------------------+------------------+------------------+-------+----+----+%s" + "| Selector Address | Local Address | Remote Address | Flags |encV|decV|%s" + "+------------------+------------------+------------------+-------+----+----+%s" , VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); /* Walk hashtab */ @@ -185,15 +185,17 @@ gtp_xdp_iptnl_vty(vty_t *vty, struct bpf_map *map) continue; } - vty_out(vty, "| %16s | %16s | %16s | %5d |%s" + vty_out(vty, "| %16s | %16s | %16s | %5d |%4d|%4d|%s" , inet_ntoa2(r[0].selector_addr, sip) , inet_ntoa2(r[0].local_addr, lip) , inet_ntoa2(r[0].remote_addr, rip) , r[0].flags + , r[0].encap_vlan_id + , r[0].decap_vlan_id , VTY_NEWLINE); } - vty_out(vty, "+------------------+------------------+------------------+-------+%s" + vty_out(vty, "+------------------+------------------+------------------+-------+----+----+%s" , VTY_NEWLINE); free(r); return 0;