Skip to content

Commit

Permalink
xdp: remove unrelated ppp code
Browse files Browse the repository at this point in the history
  • Loading branch information
acassen committed Mar 28, 2024
1 parent 93c0414 commit a7bc372
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 113 deletions.
2 changes: 0 additions & 2 deletions src/gtp_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
54 changes: 0 additions & 54 deletions src/gtp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down Expand Up @@ -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);
Expand Down
53 changes: 0 additions & 53 deletions src/gtp_xdp_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -296,39 +264,18 @@ 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);
}

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);
}
2 changes: 1 addition & 1 deletion src/gtp_xdp_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/include/gtp_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/include/gtp_xdp_ppp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down

0 comments on commit a7bc372

Please sign in to comment.