Skip to content

Commit ddb5b48

Browse files
gpziembalouberger
authored andcommitted
bgpd: vpn-vrf route leaking
- add "debug bgp vpn label" CLI - improved debug messages for "debug bgp bestpath" - send vrf label to zebra after zebra informs bgpd of vrf_id - withdraw vrf_label from zebra if zebra informs bgpd that vrf_id is disabled Signed-off-by: G. Paul Ziemba <[email protected]>
1 parent c44bd44 commit ddb5b48

14 files changed

+2349
-27
lines changed

bgpd/bgp_debug.c

+139
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ unsigned long conf_bgp_debug_zebra;
5555
unsigned long conf_bgp_debug_allow_martians;
5656
unsigned long conf_bgp_debug_nht;
5757
unsigned long conf_bgp_debug_update_groups;
58+
unsigned long conf_bgp_debug_vpn;
5859

5960
unsigned long term_bgp_debug_as4;
6061
unsigned long term_bgp_debug_neighbor_events;
@@ -68,6 +69,7 @@ unsigned long term_bgp_debug_zebra;
6869
unsigned long term_bgp_debug_allow_martians;
6970
unsigned long term_bgp_debug_nht;
7071
unsigned long term_bgp_debug_update_groups;
72+
unsigned long term_bgp_debug_vpn;
7173

7274
struct list *bgp_debug_neighbor_events_peers = NULL;
7375
struct list *bgp_debug_keepalive_peers = NULL;
@@ -1557,6 +1559,96 @@ DEFUN (no_debug_bgp_update_groups,
15571559
return CMD_SUCCESS;
15581560
}
15591561

1562+
DEFUN (debug_bgp_vpn,
1563+
debug_bgp_vpn_cmd,
1564+
"debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1565+
DEBUG_STR
1566+
BGP_STR
1567+
"VPN routes\n"
1568+
"leaked from vrf to vpn\n"
1569+
"leaked to vrf from vpn\n"
1570+
"route-map updates\n"
1571+
"labels\n")
1572+
{
1573+
int idx = 3;
1574+
1575+
if (argv_find(argv, argc, "leak-from-vrf", &idx)) {
1576+
if (vty->node == CONFIG_NODE)
1577+
DEBUG_ON(vpn, VPN_LEAK_FROM_VRF);
1578+
else
1579+
TERM_DEBUG_ON(vpn, VPN_LEAK_FROM_VRF);
1580+
} else if (argv_find(argv, argc, "leak-to-vrf", &idx)) {
1581+
if (vty->node == CONFIG_NODE)
1582+
DEBUG_ON(vpn, VPN_LEAK_TO_VRF);
1583+
else
1584+
TERM_DEBUG_ON(vpn, VPN_LEAK_TO_VRF);
1585+
} else if (argv_find(argv, argc, "rmap-event", &idx)) {
1586+
if (vty->node == CONFIG_NODE)
1587+
DEBUG_ON(vpn, VPN_LEAK_RMAP_EVENT);
1588+
else
1589+
TERM_DEBUG_ON(vpn, VPN_LEAK_RMAP_EVENT);
1590+
} else if (argv_find(argv, argc, "label", &idx)) {
1591+
if (vty->node == CONFIG_NODE)
1592+
DEBUG_ON(vpn, VPN_LEAK_LABEL);
1593+
else
1594+
TERM_DEBUG_ON(vpn, VPN_LEAK_LABEL);
1595+
} else {
1596+
vty_out(vty, "%% unknown debug bgp vpn keyword\n");
1597+
return CMD_WARNING_CONFIG_FAILED;
1598+
}
1599+
1600+
if (vty->node != CONFIG_NODE)
1601+
vty_out(vty, "enabled debug bgp vpn %s\n", argv[idx]->text);
1602+
1603+
return CMD_SUCCESS;
1604+
}
1605+
1606+
DEFUN (no_debug_bgp_vpn,
1607+
no_debug_bgp_vpn_cmd,
1608+
"no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1609+
NO_STR
1610+
DEBUG_STR
1611+
BGP_STR
1612+
"VPN routes\n"
1613+
"leaked from vrf to vpn\n"
1614+
"leaked to vrf from vpn\n"
1615+
"route-map updates\n"
1616+
"labels\n")
1617+
{
1618+
int idx = 4;
1619+
1620+
if (argv_find(argv, argc, "leak-from-vrf", &idx)) {
1621+
if (vty->node == CONFIG_NODE)
1622+
DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF);
1623+
else
1624+
TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF);
1625+
1626+
} else if (argv_find(argv, argc, "leak-to-vrf", &idx)) {
1627+
if (vty->node == CONFIG_NODE)
1628+
DEBUG_OFF(vpn, VPN_LEAK_TO_VRF);
1629+
else
1630+
TERM_DEBUG_OFF(vpn, VPN_LEAK_TO_VRF);
1631+
} else if (argv_find(argv, argc, "rmap-event", &idx)) {
1632+
if (vty->node == CONFIG_NODE)
1633+
DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT);
1634+
else
1635+
TERM_DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT);
1636+
} else if (argv_find(argv, argc, "label", &idx)) {
1637+
if (vty->node == CONFIG_NODE)
1638+
DEBUG_OFF(vpn, VPN_LEAK_LABEL);
1639+
else
1640+
TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL);
1641+
} else {
1642+
vty_out(vty, "%% unknown debug bgp vpn keyword\n");
1643+
return CMD_WARNING_CONFIG_FAILED;
1644+
}
1645+
1646+
if (vty->node != CONFIG_NODE)
1647+
vty_out(vty, "disabled debug bgp vpn %s\n", argv[idx]->text);
1648+
1649+
return CMD_SUCCESS;
1650+
}
1651+
15601652
DEFUN (no_debug_bgp,
15611653
no_debug_bgp_cmd,
15621654
"no debug bgp",
@@ -1589,6 +1681,10 @@ DEFUN (no_debug_bgp,
15891681
TERM_DEBUG_OFF(zebra, ZEBRA);
15901682
TERM_DEBUG_OFF(allow_martians, ALLOW_MARTIANS);
15911683
TERM_DEBUG_OFF(nht, NHT);
1684+
TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF);
1685+
TERM_DEBUG_OFF(vpn, VPN_LEAK_TO_VRF);
1686+
TERM_DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT);
1687+
TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL);
15921688
vty_out(vty, "All possible debugging has been turned off\n");
15931689

15941690
return CMD_SUCCESS;
@@ -1648,6 +1744,18 @@ DEFUN_NOSH (show_debugging_bgp,
16481744

16491745
if (BGP_DEBUG(allow_martians, ALLOW_MARTIANS))
16501746
vty_out(vty, " BGP allow martian next hop debugging is on\n");
1747+
1748+
if (BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF))
1749+
vty_out(vty,
1750+
" BGP route leak from vrf to vpn debugging is on\n");
1751+
if (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF))
1752+
vty_out(vty,
1753+
" BGP route leak to vrf from vpn debugging is on\n");
1754+
if (BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT))
1755+
vty_out(vty, " BGP vpn route-map event debugging is on\n");
1756+
if (BGP_DEBUG(vpn, VPN_LEAK_LABEL))
1757+
vty_out(vty, " BGP vpn label event debugging is on\n");
1758+
16511759
vty_out(vty, "\n");
16521760
return CMD_SUCCESS;
16531761
}
@@ -1692,6 +1800,15 @@ int bgp_debug_count(void)
16921800
if (BGP_DEBUG(allow_martians, ALLOW_MARTIANS))
16931801
ret++;
16941802

1803+
if (BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF))
1804+
ret++;
1805+
if (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF))
1806+
ret++;
1807+
if (BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT))
1808+
ret++;
1809+
if (BGP_DEBUG(vpn, VPN_LEAK_LABEL))
1810+
ret++;
1811+
16951812
return ret;
16961813
}
16971814

@@ -1768,6 +1885,23 @@ static int bgp_config_write_debug(struct vty *vty)
17681885
write++;
17691886
}
17701887

1888+
if (CONF_BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)) {
1889+
vty_out(vty, "debug bgp vpn leak-from-vrf\n");
1890+
write++;
1891+
}
1892+
if (CONF_BGP_DEBUG(vpn, VPN_LEAK_TO_VRF)) {
1893+
vty_out(vty, "debug bgp vpn leak-to-vrf\n");
1894+
write++;
1895+
}
1896+
if (CONF_BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT)) {
1897+
vty_out(vty, "debug bgp vpn rmap-event\n");
1898+
write++;
1899+
}
1900+
if (CONF_BGP_DEBUG(vpn, VPN_LEAK_LABEL)) {
1901+
vty_out(vty, "debug bgp vpn label\n");
1902+
write++;
1903+
}
1904+
17711905
return write;
17721906
}
17731907

@@ -1861,6 +1995,11 @@ void bgp_debug_init(void)
18611995
install_element(CONFIG_NODE, &no_debug_bgp_bestpath_cmd);
18621996
install_element(ENABLE_NODE, &no_debug_bgp_bestpath_prefix_cmd);
18631997
install_element(CONFIG_NODE, &no_debug_bgp_bestpath_prefix_cmd);
1998+
1999+
install_element(ENABLE_NODE, &debug_bgp_vpn_cmd);
2000+
install_element(CONFIG_NODE, &debug_bgp_vpn_cmd);
2001+
install_element(ENABLE_NODE, &no_debug_bgp_vpn_cmd);
2002+
install_element(CONFIG_NODE, &no_debug_bgp_vpn_cmd);
18642003
}
18652004

18662005
/* Return true if this prefix is on the per_prefix_list of prefixes to debug

bgpd/bgp_debug.h

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern unsigned long conf_bgp_debug_zebra;
7272
extern unsigned long conf_bgp_debug_allow_martians;
7373
extern unsigned long conf_bgp_debug_nht;
7474
extern unsigned long conf_bgp_debug_update_groups;
75+
extern unsigned long conf_bgp_debug_vpn;
7576

7677
extern unsigned long term_bgp_debug_as4;
7778
extern unsigned long term_bgp_debug_neighbor_events;
@@ -83,6 +84,7 @@ extern unsigned long term_bgp_debug_zebra;
8384
extern unsigned long term_bgp_debug_allow_martians;
8485
extern unsigned long term_bgp_debug_nht;
8586
extern unsigned long term_bgp_debug_update_groups;
87+
extern unsigned long term_bgp_debug_vpn;
8688

8789
extern struct list *bgp_debug_neighbor_events_peers;
8890
extern struct list *bgp_debug_keepalive_peers;
@@ -111,6 +113,10 @@ struct bgp_debug_filter {
111113
#define BGP_DEBUG_ALLOW_MARTIANS 0x01
112114
#define BGP_DEBUG_NHT 0x01
113115
#define BGP_DEBUG_UPDATE_GROUPS 0x01
116+
#define BGP_DEBUG_VPN_LEAK_FROM_VRF 0x01
117+
#define BGP_DEBUG_VPN_LEAK_TO_VRF 0x02
118+
#define BGP_DEBUG_VPN_LEAK_RMAP_EVENT 0x04
119+
#define BGP_DEBUG_VPN_LEAK_LABEL 0x08
114120

115121
#define BGP_DEBUG_PACKET_SEND 0x01
116122
#define BGP_DEBUG_PACKET_SEND_DETAIL 0x02

bgpd/bgp_main.c

+6
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ static int bgp_vrf_enable(struct vrf *vrf)
265265
if (old_vrf_id != bgp->vrf_id)
266266
bgp_update_redist_vrf_bitmaps(bgp, old_vrf_id);
267267
bgp_instance_up(bgp);
268+
vpn_leak_zebra_vrf_label_update(bgp, AFI_IP);
269+
vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6);
268270
}
269271

270272
return 0;
@@ -283,6 +285,10 @@ static int bgp_vrf_disable(struct vrf *vrf)
283285

284286
bgp = bgp_lookup_by_name(vrf->name);
285287
if (bgp) {
288+
289+
vpn_leak_zebra_vrf_label_withdraw(bgp, AFI_IP);
290+
vpn_leak_zebra_vrf_label_withdraw(bgp, AFI_IP6);
291+
286292
old_vrf_id = bgp->vrf_id;
287293
bgp_handle_socket(bgp, vrf, VRF_UNKNOWN, false);
288294
/* We have instance configured, unlink from VRF and make it

0 commit comments

Comments
 (0)