Skip to content

Commit

Permalink
zebra: vlan to dplane, Relocating some functions
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
raja-rajasekar committed Sep 25, 2024
1 parent 51b19f9 commit 1632988
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 65 deletions.
65 changes: 1 addition & 64 deletions zebra/if_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "zebra/zebra_l2.h"
#include "zebra/netconf_netlink.h"
#include "zebra/zebra_trace.h"
#include "zebra/zebra_vxlan.h"

extern struct zebra_privs_t zserv_privs;

Expand Down Expand Up @@ -1816,70 +1817,6 @@ int netlink_tunneldump_read(struct zebra_ns *zns)
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
*
Expand Down
64 changes: 64 additions & 0 deletions zebra/zebra_vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "zebra/zebra_evpn_mh.h"
#include "zebra/zebra_evpn_vxlan.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, ZL3VNI, "L3 VNI hash");
Expand Down Expand Up @@ -6246,3 +6248,65 @@ extern void zebra_evpn_init(void)
{
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);
}
6 changes: 5 additions & 1 deletion zebra/zebra_vxlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
}
#endif
Expand Down

0 comments on commit 1632988

Please sign in to comment.