zebra: vlan to dplane, Relocating some functions

Relocating functions used by vlan in if_netlink into zebra vxlan

Note: Static variable to the functions will be added back in the next
commit.

Ticket :#3878175

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
This commit is contained in:
Rajasekar Raja 2024-08-06 11:46:45 -07:00
parent 51b19f9ce3
commit 1632988acf
3 changed files with 70 additions and 65 deletions

View file

@ -63,6 +63,7 @@
#include "zebra/zebra_l2.h" #include "zebra/zebra_l2.h"
#include "zebra/netconf_netlink.h" #include "zebra/netconf_netlink.h"
#include "zebra/zebra_trace.h" #include "zebra/zebra_trace.h"
#include "zebra/zebra_vxlan.h"
extern struct zebra_privs_t zserv_privs; extern struct zebra_privs_t zserv_privs;
@ -1816,70 +1817,6 @@ int netlink_tunneldump_read(struct zebra_ns *zns)
return 0; return 0;
} }
static const char *port_state2str(uint8_t state)
{
switch (state) {
case BR_STATE_DISABLED:
return "DISABLED";
case BR_STATE_LISTENING:
return "LISTENING";
case BR_STATE_LEARNING:
return "LEARNING";
case BR_STATE_FORWARDING:
return "FORWARDING";
case BR_STATE_BLOCKING:
return "BLOCKING";
}
return "UNKNOWN";
}
static void vxlan_vni_state_change(struct zebra_if *zif, uint16_t id,
uint8_t state)
{
struct zebra_vxlan_vni *vnip;
vnip = zebra_vxlan_if_vlanid_vni_find(zif, id);
if (!vnip) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"Cannot find VNI for VID (%u) IF %s for vlan state update",
id, zif->ifp->name);
return;
}
switch (state) {
case BR_STATE_FORWARDING:
zebra_vxlan_if_vni_up(zif->ifp, vnip);
break;
case BR_STATE_BLOCKING:
zebra_vxlan_if_vni_down(zif->ifp, vnip);
break;
case BR_STATE_DISABLED:
case BR_STATE_LISTENING:
case BR_STATE_LEARNING:
default:
/* Not used for anything at the moment */
break;
}
}
static void vlan_id_range_state_change(struct interface *ifp, uint16_t id_start,
uint16_t id_end, uint8_t state)
{
struct zebra_if *zif;
zif = (struct zebra_if *)ifp->info;
if (!zif)
return;
for (uint16_t i = id_start; i <= id_end; i++)
vxlan_vni_state_change(zif, i, state);
}
/** /**
* netlink_vlan_change() - Read in change about vlans from the kernel * netlink_vlan_change() - Read in change about vlans from the kernel
* *

View file

@ -41,6 +41,8 @@
#include "zebra/zebra_evpn_mh.h" #include "zebra/zebra_evpn_mh.h"
#include "zebra/zebra_evpn_vxlan.h" #include "zebra/zebra_evpn_vxlan.h"
#include "zebra/zebra_router.h" #include "zebra/zebra_router.h"
#include "zebra/zebra_trace.h"
#include <linux/if_bridge.h>
DEFINE_MTYPE_STATIC(ZEBRA, HOST_PREFIX, "host prefix"); DEFINE_MTYPE_STATIC(ZEBRA, HOST_PREFIX, "host prefix");
DEFINE_MTYPE_STATIC(ZEBRA, ZL3VNI, "L3 VNI hash"); DEFINE_MTYPE_STATIC(ZEBRA, ZL3VNI, "L3 VNI hash");
@ -6246,3 +6248,65 @@ extern void zebra_evpn_init(void)
{ {
hook_register(zserv_client_close, zebra_evpn_cfg_clean_up); hook_register(zserv_client_close, zebra_evpn_cfg_clean_up);
} }
const char *port_state2str(uint8_t state)
{
switch (state) {
case BR_STATE_DISABLED:
return "DISABLED";
case BR_STATE_LISTENING:
return "LISTENING";
case BR_STATE_LEARNING:
return "LEARNING";
case BR_STATE_FORWARDING:
return "FORWARDING";
case BR_STATE_BLOCKING:
return "BLOCKING";
}
return "UNKNOWN";
}
void vxlan_vni_state_change(struct zebra_if *zif, uint16_t id, uint8_t state)
{
struct zebra_vxlan_vni *vnip;
vnip = zebra_vxlan_if_vlanid_vni_find(zif, id);
if (!vnip) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("Cannot find VNI for VID (%u) IF %s for vlan state update",
id, zif->ifp->name);
return;
}
switch (state) {
case BR_STATE_FORWARDING:
zebra_vxlan_if_vni_up(zif->ifp, vnip);
break;
case BR_STATE_BLOCKING:
zebra_vxlan_if_vni_down(zif->ifp, vnip);
break;
case BR_STATE_DISABLED:
case BR_STATE_LISTENING:
case BR_STATE_LEARNING:
default:
/* Not used for anything at the moment */
break;
}
}
void vlan_id_range_state_change(struct interface *ifp, uint16_t id_start,
uint16_t id_end, uint8_t state)
{
struct zebra_if *zif;
zif = (struct zebra_if *)ifp->info;
if (!zif)
return;
for (uint16_t i = id_start; i <= id_end; i++)
vxlan_vni_state_change(zif, i, state);
}

View file

@ -221,7 +221,11 @@ extern int zebra_vxlan_dp_network_mac_del(struct interface *ifp,
extern void zebra_vxlan_set_accept_bgp_seq(bool set); extern void zebra_vxlan_set_accept_bgp_seq(bool set);
extern bool zebra_vxlan_get_accept_bgp_seq(void); extern bool zebra_vxlan_get_accept_bgp_seq(void);
extern void vlan_id_range_state_change(struct interface *ifp, uint16_t id_start,
uint16_t id_end, uint8_t state);
extern void vxlan_vni_state_change(struct zebra_if *zif, uint16_t id,
uint8_t state);
extern const char *port_state2str(uint8_t state);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif