From a7bc3724d954d75293ae2690c49272ea72336ac2 Mon Sep 17 00:00:00 2001 From: Alexandre Cassen Date: Thu, 28 Mar 2024 17:02:01 +0100 Subject: [PATCH] xdp: remove unrelated ppp code --- src/gtp_data.c | 2 -- src/gtp_vty.c | 54 --------------------------------------- src/gtp_xdp_ppp.c | 53 -------------------------------------- src/gtp_xdp_rt.c | 2 +- src/include/gtp_data.h | 2 -- src/include/gtp_xdp_ppp.h | 1 - 6 files changed, 1 insertion(+), 113 deletions(-) diff --git a/src/gtp_data.c b/src/gtp_data.c index 91ccd03..c6f13e8 100644 --- a/src/gtp_data.c +++ b/src/gtp_data.c @@ -155,8 +155,6 @@ free_daemon_data(void) gtp_xdp_mirror_unload(&daemon_data->xdp_mirror); if (__test_bit(GTP_FL_GTP_ROUTE_LOADED_BIT, &daemon_data->flags)) gtp_xdp_rt_unload(&daemon_data->xdp_gtp_route); - if (__test_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags)) - gtp_xdp_ppp_unload(&daemon_data->xdp_ppp_ingress); gtp_switch_server_destroy(); gtp_router_server_destroy(); gtp_request_destroy(); diff --git a/src/gtp_vty.c b/src/gtp_vty.c index 520b120..3c1c318 100644 --- a/src/gtp_vty.c +++ b/src/gtp_vty.c @@ -295,58 +295,6 @@ DEFUN(no_pdn_xdp_mirror, return CMD_SUCCESS; } -DEFUN(pdn_xdp_ppp_ingress, - pdn_xdp_ppp_ingress_cmd, - "xdp-ppp-ingress STRING interface STRING [xdp-prog STRING]", - "PPP Ingress XDP program\n" - "path to BPF file\n" - "Interface name\n" - "Name" - "XDP Program Name" - "Name") -{ - int ret; - - if (__test_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags)) { - vty_out(vty, "%% PPP Ingress XDP program already loaded.%s" - , VTY_NEWLINE); - return CMD_WARNING; - } - - ret = gtp_bpf_opts_load(&daemon_data->xdp_ppp_ingress, vty, argc, argv, - gtp_xdp_ppp_load); - if (ret < 0) - return CMD_WARNING; - - __set_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags); - return CMD_SUCCESS; -} - -DEFUN(no_pdn_xdp_ppp_ingress, - no_pdn_xdp_ppp_ingress_cmd, - "no xdp-ppp-ingress", - "PPP Ingress XDP program\n") -{ - gtp_bpf_opts_t *opts = &daemon_data->xdp_ppp_ingress; - - if (!__test_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags)) { - vty_out(vty, "%% No PPP Ingress XDP program is currently configured. Ignoring%s" - , VTY_NEWLINE); - return CMD_WARNING; - } - - gtp_xdp_mirror_unload(opts); - - /* Reset data */ - memset(opts, 0, sizeof(gtp_bpf_opts_t)); - - vty_out(vty, "Success unloading eBPF program:%s%s" - , opts->filename - , VTY_NEWLINE); - __clear_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags); - return CMD_SUCCESS; -} - DEFUN(pdn_bpf_ppp_rps, pdn_bpf_ppp_rps_cmd, "bpf-ppp-rps STRING [xdp-prog STRING]", @@ -935,8 +883,6 @@ gtp_vty_init(void) install_element(PDN_NODE, &no_pdn_xdp_gtpu_cmd); install_element(PDN_NODE, &pdn_xdp_mirror_cmd); install_element(PDN_NODE, &no_pdn_xdp_mirror_cmd); - install_element(PDN_NODE, &pdn_xdp_ppp_ingress_cmd); - install_element(PDN_NODE, &no_pdn_xdp_ppp_ingress_cmd); install_element(PDN_NODE, &pdn_bpf_ppp_rps_cmd); install_element(PDN_NODE, &no_pdn_bpf_ppp_rps_cmd); install_element(PDN_NODE, &pdn_mirror_cmd); diff --git a/src/gtp_xdp_ppp.c b/src/gtp_xdp_ppp.c index e00d4c6..a3fac9f 100644 --- a/src/gtp_xdp_ppp.c +++ b/src/gtp_xdp_ppp.c @@ -41,38 +41,6 @@ /* Extern data */ extern data_t *daemon_data; -/* Local data */ -static xdp_exported_maps_t xdp_ppp_maps[XDP_RT_MAP_CNT] = { 0 }; - - -/* - * XDP PPP BPF related - */ -int -gtp_xdp_ppp_load(gtp_bpf_opts_t *opts) -{ - struct bpf_map *map; - int err; - - err = gtp_xdp_load(opts); - if (err < 0) - return -1; - - map = gtp_bpf_load_map(opts->bpf_obj, "ppp_ingress"); - if (!map) { - gtp_xdp_unload(opts); - return -1; - } - xdp_ppp_maps[XDP_RT_MAP_PPP_INGRESS].map = map; - return 0; -} - -void -gtp_xdp_ppp_unload(gtp_bpf_opts_t *opts) -{ - gtp_xdp_unload(opts); -} - /* * PPP Handling @@ -296,14 +264,9 @@ int gtp_xdp_ppp_action(int action, gtp_teid_t *t, struct bpf_map *map_ingress, struct bpf_map *map_egress) { - struct bpf_map *map_ppp_ingress = xdp_ppp_maps[XDP_RT_MAP_PPP_INGRESS].map; - if (__test_bit(GTP_TEID_FL_EGRESS, &t->flags)) return gtp_xdp_ppp_map_action(map_egress, action, t); - if (__test_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags)) - return gtp_xdp_ppp_map_action(map_ppp_ingress, action, t); - return gtp_xdp_ppp_map_action(map_ingress, action, t); } @@ -311,24 +274,8 @@ int gtp_xdp_ppp_teid_vty(vty_t *vty, gtp_teid_t *t, struct bpf_map *map_ingress, struct bpf_map *map_egress) { - struct bpf_map *map_ppp_ingress = xdp_ppp_maps[XDP_RT_MAP_PPP_INGRESS].map; - if (__test_bit(GTP_TEID_FL_EGRESS, &t->flags)) return gtp_xdp_teid_vty(map_egress, vty, t); - if (__test_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags)) - return gtp_xdp_teid_vty(map_ppp_ingress, vty, t); - return gtp_xdp_teid_vty(map_ingress, vty, t); } - -int -gtp_xdp_ppp_vty(vty_t *vty, struct bpf_map *map_ingress) -{ - struct bpf_map *map_ppp_ingress = xdp_ppp_maps[XDP_RT_MAP_PPP_INGRESS].map; - - if (__test_bit(GTP_FL_PPP_INGRESS_LOADED_BIT, &daemon_data->flags)) - return gtp_xdp_teid_vty(map_ppp_ingress, vty, NULL); - - return gtp_xdp_teid_vty(map_ingress, vty, NULL); -} \ No newline at end of file diff --git a/src/gtp_xdp_rt.c b/src/gtp_xdp_rt.c index 5d187ec..6c0cac4 100644 --- a/src/gtp_xdp_rt.c +++ b/src/gtp_xdp_rt.c @@ -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_ppp_vty(vty, bpf_opts->bpf_maps[XDP_RT_MAP_PPP_INGRESS].map); + gtp_xdp_teid_vty(bpf_opts->bpf_maps[XDP_RT_MAP_PPP_INGRESS].map, vty, NULL); vty_out(vty, "+------------+------------------+-----------+--------------+---------------------+%s" , VTY_NEWLINE); return 0; diff --git a/src/include/gtp_data.h b/src/include/gtp_data.h index 23eceb6..c1fb3ad 100644 --- a/src/include/gtp_data.h +++ b/src/include/gtp_data.h @@ -37,7 +37,6 @@ enum daemon_flags { GTP_FL_GTP_ROUTE_LOADED_BIT, GTP_FL_GTPU_LOADED_BIT, GTP_FL_MIRROR_LOADED_BIT, - GTP_FL_PPP_INGRESS_LOADED_BIT, GTP_FL_PPP_RPS_LOADED_BIT, GTP_FL_RESTART_COUNTER_LOADED_BIT, }; @@ -74,7 +73,6 @@ typedef struct _data { gtp_bpf_opts_t xdp_gtp_route; gtp_bpf_opts_t xdp_gtpu; gtp_bpf_opts_t xdp_mirror; - gtp_bpf_opts_t xdp_ppp_ingress; gtp_bpf_opts_t bpf_ppp_rps; char restart_counter_filename[GTP_STR_MAX_LEN]; uint8_t restart_counter; diff --git a/src/include/gtp_xdp_ppp.h b/src/include/gtp_xdp_ppp.h index 40577db..b9fde6b 100644 --- a/src/include/gtp_xdp_ppp.h +++ b/src/include/gtp_xdp_ppp.h @@ -30,7 +30,6 @@ struct ppp_key { /* Prototypes */ extern int gtp_xdp_ppp_action(int, gtp_teid_t *, struct bpf_map *, struct bpf_map *); extern int gtp_xdp_ppp_teid_vty(vty_t *, gtp_teid_t *, struct bpf_map *, struct bpf_map *); -extern int gtp_xdp_ppp_vty(vty_t *, struct bpf_map *); extern int gtp_xdp_ppp_load(gtp_bpf_opts_t *); extern void gtp_xdp_ppp_unload(gtp_bpf_opts_t *);