Skip to content

Commit

Permalink
vrf: Add support to pppoe-bundle
Browse files Browse the repository at this point in the history
VRF can only reference one pppoe instance or one pppoe bundle.
  • Loading branch information
acassen committed Apr 4, 2024
1 parent dee156a commit 772fbc5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/gtp_vrf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ DEFUN(ip_vrf_pppoe,
return CMD_WARNING;
}

if (__test_bit(IP_VRF_FL_PPPOE_BUNDLE_BIT, &vrf->flags)) {
vty_out(vty, "%% PPPoE Bundle already configured!%s", VTY_NEWLINE);
return CMD_WARNING;
}

pppoe = gtp_pppoe_get_by_name(argv[0]);
if (!pppoe) {
vty_out(vty, "%% unknown PPPoE instance %s!%s", argv[0], VTY_NEWLINE);
Expand All @@ -305,6 +310,42 @@ DEFUN(ip_vrf_pppoe,
return CMD_SUCCESS;
}

DEFUN(ip_vrf_pppoe_bundle,
ip_vrf_pppoe_bundle_cmd,
"pppoe bundle STRING",
"PPP Over Ethernet support\n"
"Bundle\n"
"NAME\n")
{
ip_vrf_t *vrf = vty->index;
gtp_pppoe_bundle_t *bundle;

if (argc < 1) {
vty_out(vty, "%% missing arguments%s", VTY_NEWLINE);
return CMD_WARNING;
}

if (__test_bit(IP_VRF_FL_PPPOE_BIT, &vrf->flags)) {
vty_out(vty, "%% PPPoE Instance already configured!%s", VTY_NEWLINE);
return CMD_WARNING;
}

if (__test_bit(IP_VRF_FL_PPPOE_BUNDLE_BIT, &vrf->flags)) {
vty_out(vty, "%% PPPoE Bundle already configured!%s", VTY_NEWLINE);
return CMD_WARNING;
}

bundle = gtp_pppoe_bundle_get_by_name(argv[0]);
if (!bundle) {
vty_out(vty, "%% unknown PPPoE bundle %s!%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}

vrf->pppoe_bundle = bundle;
__set_bit(IP_VRF_FL_PPPOE_BUNDLE_BIT, &vrf->flags);
return CMD_SUCCESS;
}


/*
* Show commands
Expand Down Expand Up @@ -345,6 +386,7 @@ gtp_config_write(vty_t *vty)
{
list_head_t *l = &daemon_data->ip_vrf;
gtp_pppoe_t *pppoe;
gtp_pppoe_bundle_t *bundle;
ip_vrf_t *vrf;

list_for_each_entry(vrf, l, next) {
Expand All @@ -368,6 +410,10 @@ gtp_config_write(vty_t *vty)
pppoe = vrf->pppoe;
vty_out(vty, " pppoe instance %s%s", pppoe->name, VTY_NEWLINE);
}
if (__test_bit(IP_VRF_FL_PPPOE_BUNDLE_BIT, &vrf->flags)) {
bundle = vrf->pppoe_bundle;
vty_out(vty, " pppoe bundle %s%s", bundle->name, VTY_NEWLINE);
}
vty_out(vty, "!%s", VTY_NEWLINE);
}

Expand Down Expand Up @@ -396,6 +442,7 @@ gtp_vrf_vty_init(void)
install_element(IP_VRF_NODE, &ip_vrf_decapsulation_dot1q_cmd);
install_element(IP_VRF_NODE, &ip_vrf_encapsulation_ipip_cmd);
install_element(IP_VRF_NODE, &ip_vrf_pppoe_cmd);
install_element(IP_VRF_NODE, &ip_vrf_pppoe_bundle_cmd);

/* Install show commands. */
install_element(VIEW_NODE, &show_ip_vrf_cmd);
Expand Down
2 changes: 2 additions & 0 deletions src/include/gtp_vrf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum ip_vrf_flags {
IP_VRF_FL_DECAP_DOT1Q_BIT,
IP_VRF_FL_IPIP_BIT,
IP_VRF_FL_PPPOE_BIT,
IP_VRF_FL_PPPOE_BUNDLE_BIT,
IP_VRF_FL_DIRECT_TX_BIT,
IP_VRF_FL_GTP_UDP_PORT_LEARNING_BIT,
};
Expand All @@ -39,6 +40,7 @@ typedef struct _ip_vrf {
uint16_t decap_vlan_id;
gtp_iptnl_t iptnl;
gtp_pppoe_t *pppoe;
gtp_pppoe_bundle_t *pppoe_bundle;

list_head_t next;

Expand Down

0 comments on commit 772fbc5

Please sign in to comment.