Skip to content

Commit

Permalink
Merge branch 'FRRouting:master' into 202404092101
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-run authored May 22, 2024
2 parents 6406af0 + 4bd1648 commit 29ad4e0
Show file tree
Hide file tree
Showing 31 changed files with 305 additions and 133 deletions.
4 changes: 3 additions & 1 deletion bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -6317,9 +6317,11 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
void bgp_evpn_free(struct bgp *bgp, struct bgpevpn *vpn)
{
struct bgp_dest *dest = NULL;
uint32_t ann_count = zebra_announce_count(&bm->zebra_announce_head);

while (zebra_announce_count(&bm->zebra_announce_head)) {
while (ann_count) {
dest = zebra_announce_pop(&bm->zebra_announce_head);
ann_count--;
if (dest->za_vpn == vpn) {
bgp_path_info_unlock(dest->za_bgp_pi);
bgp_dest_unlock_node(dest);
Expand Down
3 changes: 3 additions & 0 deletions bgpd/bgp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "bfd.h"
#include "libfrr.h"
#include "ns.h"
#include "libagentx.h"

#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"
Expand Down Expand Up @@ -516,8 +517,10 @@ int main(int argc, char **argv)
bgp_option_set(BGP_OPT_NO_ZEBRA);
bgp_error_init();
/* Initializations. */
libagentx_init();
bgp_vrf_init();


#ifdef HAVE_SCRIPTING
bgp_script_init();
#endif
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,8 @@ static int bgp_capability_software_version(struct peer *peer,
peer->soft_version = XSTRDUP(MTYPE_BGP_SOFT_VERSION, str);

if (bgp_debug_neighbor_events(peer))
zlog_debug("%s sent Software Version: %s", peer->host,
peer->soft_version);
zlog_debug("%s received Software Version: %s",
peer->host, peer->soft_version);
}

return 0;
Expand Down
3 changes: 1 addition & 2 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -3810,8 +3810,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
*/
if (old_select &&
is_route_parent_evpn(old_select))
bgp_zebra_route_install(dest, old_select, bgp,
false, NULL, false);
bgp_zebra_withdraw_actual(dest, old_select, bgp);

bgp_zebra_route_install(dest, new_select, bgp, true,
NULL, false);
Expand Down
38 changes: 17 additions & 21 deletions bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -5234,27 +5234,23 @@ DEFPY_YANG (match_peer,

nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);

if (addrv4_str) {
snprintf(
xpath_value, sizeof(xpath_value),
"%s/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
addrv4_str);
} else if (addrv6_str) {
snprintf(
xpath_value, sizeof(xpath_value),
"%s/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
addrv6_str);
} else {
snprintf(
xpath_value, sizeof(xpath_value),
"%s/rmap-match-condition/frr-bgp-route-map:peer-interface",
xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, intf);
}
snprintf(xpath_value, sizeof(xpath_value),
"%s/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
xpath);
nb_cli_enqueue_change(vty, xpath_value,
addrv4_str ? NB_OP_MODIFY : NB_OP_DESTROY,
addrv4_str);
snprintf(xpath_value, sizeof(xpath_value),
"%s/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
xpath);
nb_cli_enqueue_change(vty, xpath_value,
addrv6_str ? NB_OP_MODIFY : NB_OP_DESTROY,
addrv6_str);
snprintf(xpath_value, sizeof(xpath_value),
"%s/rmap-match-condition/frr-bgp-route-map:peer-interface",
xpath);
nb_cli_enqueue_change(vty, xpath_value,
intf ? NB_OP_MODIFY : NB_OP_DESTROY, intf);

return nb_cli_apply_changes(vty, NULL);
}
Expand Down
9 changes: 2 additions & 7 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1891,11 +1891,9 @@ static void bgp_zebra_buffer_write_ready(void)
* save new pi, mark as going to be
* withdrawan, remove install flag
*
* Withdrawal Install Special case, send withdrawal immediately
* Leave dest on list, release old pi,
* Withdrawal Install Leave dest on list, release old pi,
* save new pi, mark as going to be
* installed. <see note about evpn
* in bgp_route.c in bgp_process_main_one>
* installed.
* Withdrawal Withdrawal Leave dest on list, release old pi,
* save new pi, mark as going to be
* withdrawn.
Expand Down Expand Up @@ -1950,9 +1948,6 @@ void bgp_zebra_route_install(struct bgp_dest *dest, struct bgp_path_info *info,
dest->za_bgp_pi = info;
} else if (CHECK_FLAG(dest->flags, BGP_NODE_SCHEDULE_FOR_DELETE)) {
assert(dest->za_bgp_pi);
if (install & !is_evpn)
bgp_zebra_withdraw_actual(dest, dest->za_bgp_pi, bgp);

bgp_path_info_unlock(dest->za_bgp_pi);
bgp_path_info_lock(info);
dest->za_bgp_pi = info;
Expand Down
4 changes: 3 additions & 1 deletion bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3908,11 +3908,13 @@ int bgp_delete(struct bgp *bgp)
int i;
struct bgp_dest *dest = NULL;
struct graceful_restart_info *gr_info;
uint32_t ann_count = zebra_announce_count(&bm->zebra_announce_head);

assert(bgp);

while (zebra_announce_count(&bm->zebra_announce_head)) {
while (ann_count) {
dest = zebra_announce_pop(&bm->zebra_announce_head);
ann_count--;
if (dest->za_bgp_pi->peer->bgp == bgp) {
bgp_path_info_unlock(dest->za_bgp_pi);
bgp_dest_unlock_node(dest);
Expand Down
30 changes: 21 additions & 9 deletions doc/user/zebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1453,29 +1453,41 @@ To program the PBR rules as rte_flows you additionally need to configure
zebra Terminal Mode Commands
============================

.. clicmd:: show ip route
.. clicmd:: show [ip|ipv6] route

Display current routes which zebra holds in its database.

::

Router# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
B - BGP * - FIB route.
Codes: K - kernel route, C - connected, L - local, S - static,
R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric, t - Table-Direct,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure

K* 0.0.0.0/0 203.181.89.241
S 0.0.0.0/0 203.181.89.1
C* 127.0.0.0/8 lo
C* 203.181.89.240/28 eth0
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 00:30:22
S> 4.5.6.7/32 [1/0] via 192.168.119.1 (recursive), weight 1, 00:30:22
* via 192.168.119.1, enp13s0, weight 1, 00:30:22
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr2 linkdown, 00:30:22
L>* 192.168.119.205/32 is directly connected, enp13s0, 00:30:22


.. clicmd:: show ipv6 route

.. clicmd:: show [ip|ipv6] route [PREFIX] [nexthop-group]

Display detailed information about a route. If [nexthop-group] is
included, it will display the nexthop group ID the route is using as well.

.. clicmd:: show [ip|ipv6] route summary

Display summary information about routes received from each protocol.
This command displays the entries received from each route and as such
this total can be more than the actual number of FIB routes. Finally
due to the way that linux supports local and connected routes the FIB
total may not be exactly what is shown in the equivalent `ip route show`
command to see the state of the linux kernel.

.. clicmd:: show interface [NAME] [{vrf VRF|brief}] [json]

.. clicmd:: show interface [NAME] [{vrf all|brief}] [json]
Expand Down
3 changes: 3 additions & 0 deletions eigrpd/eigrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "distribute.h"
#include "libfrr.h"
#include "routemap.h"
#include "libagentx.h"
//#include "if_rmap.h"

#include "eigrpd/eigrp_structs.h"
Expand Down Expand Up @@ -178,9 +179,11 @@ int main(int argc, char **argv, char **envp)

/* EIGRP master init. */
eigrp_master_init();

eigrp_om->master = frr_init();
master = eigrp_om->master;

libagentx_init();
eigrp_error_init();
eigrp_vrf_init();
vrf_init(NULL, NULL, NULL, NULL);
Expand Down
2 changes: 2 additions & 0 deletions isisd/isis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "libfrr.h"
#include "routemap.h"
#include "affinitymap.h"
#include "libagentx.h"

#include "isisd/isis_affinitymap.h"
#include "isisd/isis_constants.h"
Expand Down Expand Up @@ -307,6 +308,7 @@ int main(int argc, char **argv, char **envp)
/*
* initializations
*/
libagentx_init();
cmd_init_config_callbacks(isis_config_start, isis_config_end);
isis_error_init();
access_list_init();
Expand Down
3 changes: 2 additions & 1 deletion isisd/isis_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3821,7 +3821,8 @@ int lib_interface_isis_circuit_type_modify(struct nb_cb_modify_args *args)
case NB_EV_APPLY:
circuit = nb_running_get_entry(args->dnode, NULL, true);
circuit->is_type_config = circ_type;
isis_circuit_is_type_set(circuit, circ_type);
if (!circuit->area || circuit->area->is_type == IS_LEVEL_1_AND_2)
isis_circuit_is_type_set(circuit, circ_type);
break;
}

Expand Down
2 changes: 2 additions & 0 deletions ldpd/ldpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "libfrr.h"
#include "lib_errors.h"
#include "zlog_recirculate.h"
#include "libagentx.h"

static void ldpd_shutdown(void);
static pid_t start_child(enum ldpd_process, char *, int, int, int);
Expand Down Expand Up @@ -370,6 +371,7 @@ main(int argc, char *argv[])
zlog_recirculate_subscribe(master, pipe_lde_log[0]);
zlog_recirculate_subscribe(master, pipe_ldpe_log[0]);

libagentx_init();
vrf_init(NULL, NULL, NULL, NULL);
access_list_init();
ldp_vty_init();
Expand Down
44 changes: 10 additions & 34 deletions lib/agentx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
#include "hook.h"
#include "libfrr.h"
#include "xref.h"
#include "lib/libagentx.h"

XREF_SETUP();

DEFINE_HOOK(agentx_enabled, (), ());

static bool agentx_enabled = false;
//bool agentx_enabled = false;

static struct event_loop *agentx_tm;
static struct event *timeout_thr = NULL;
Expand Down Expand Up @@ -153,15 +154,6 @@ static void agentx_events_update(void)
netsnmp_large_fd_set_cleanup(&lfds);
}

/* AgentX node. */
static int config_write_agentx(struct vty *vty);
static struct cmd_node agentx_node = {
.name = "smux",
.node = SMUX_NODE,
.prompt = "",
.config_write = config_write_agentx,
};

/* Logging NetSNMP messages */
static int agentx_log_callback(int major, int minor, void *serverarg,
void *clientarg)
Expand Down Expand Up @@ -201,17 +193,7 @@ static int agentx_log_callback(int major, int minor, void *serverarg,
return SNMP_ERR_NOERROR;
}

static int config_write_agentx(struct vty *vty)
{
if (agentx_enabled)
vty_out(vty, "agentx\n");
return 1;
}

DEFUN (agentx_enable,
agentx_enable_cmd,
"agentx",
"SNMP AgentX protocol settings\n")
static int agentx_cli_on(void)
{
if (!agentx_enabled) {
init_snmp(FRR_SMUX_NAME);
Expand All @@ -221,19 +203,14 @@ DEFUN (agentx_enable,
hook_call(agentx_enabled);
}

return CMD_SUCCESS;
return 1;
}

DEFUN (no_agentx,
no_agentx_cmd,
"no agentx",
NO_STR
"SNMP AgentX protocol settings\n")
static int agentx_cli_off(void)
{
if (!agentx_enabled)
return CMD_SUCCESS;
vty_out(vty, "SNMP AgentX support cannot be disabled once enabled\n");
return CMD_WARNING_CONFIG_FAILED;
return 1;
return 0;
}

static int smux_disable(void)
Expand All @@ -252,17 +229,16 @@ void smux_init(struct event_loop *tm)
{
agentx_tm = tm;

hook_register(agentx_cli_enabled, agentx_cli_on);
hook_register(agentx_cli_disabled, agentx_cli_off);

netsnmp_enable_subagent();
snmp_disable_log();
snmp_enable_calllog();
snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_LOGGING,
agentx_log_callback, NULL);
init_agent(FRR_SMUX_NAME);

install_node(&agentx_node);
install_element(CONFIG_NODE, &agentx_enable_cmd);
install_element(CONFIG_NODE, &no_agentx_cmd);

hook_register(frr_early_fini, smux_disable);
}

Expand Down
Loading

0 comments on commit 29ad4e0

Please sign in to comment.