summaryrefslogtreecommitdiff
path: root/zebra/zebra_vxlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vxlan.c')
-rw-r--r--zebra/zebra_vxlan.c132
1 files changed, 59 insertions, 73 deletions
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index d3ede66fb0..256fa9e4b7 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -1157,8 +1157,7 @@ static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, cmd, VRF_DEFAULT);
stream_putl(s, vni);
@@ -1195,7 +1194,7 @@ static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,
else
client->macipdel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -2565,8 +2564,7 @@ static int zvni_send_add_to_client(zebra_vni_t *zvni)
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, ZEBRA_VNI_ADD, VRF_DEFAULT);
stream_putl(s, zvni->vni);
@@ -2583,7 +2581,7 @@ static int zvni_send_add_to_client(zebra_vni_t *zvni)
zebra_route_string(client->proto));
client->vniadd_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -2599,7 +2597,7 @@ static int zvni_send_del_to_client(vni_t vni)
if (!client)
return 0;
- s = client->obuf;
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
stream_reset(s);
zclient_create_header(s, ZEBRA_VNI_DEL, VRF_DEFAULT);
@@ -2613,7 +2611,7 @@ static int zvni_send_del_to_client(vni_t vni)
zebra_route_string(client->proto));
client->vnidel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -3550,8 +3548,7 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)
memset(&rmac, 0, sizeof(struct ethaddr));
zl3vni_get_rmac(zl3vni, &rmac);
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, ZEBRA_L3VNI_ADD, zl3vni_vrf_id(zl3vni));
stream_putl(s, zl3vni->vni);
@@ -3574,7 +3571,7 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)
zebra_route_string(client->proto));
client->l3vniadd_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -3590,8 +3587,7 @@ static int zl3vni_send_del_to_client(zebra_l3vni_t *zl3vni)
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, ZEBRA_L3VNI_DEL, zl3vni_vrf_id(zl3vni));
stream_putl(s, zl3vni->vni);
@@ -3605,7 +3601,7 @@ static int zl3vni_send_del_to_client(zebra_l3vni_t *zl3vni)
zebra_route_string(client->proto));
client->l3vnidel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni)
@@ -3723,8 +3719,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p,
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, cmd, vrf_id);
stream_put(s, p, sizeof(struct prefix));
@@ -3743,7 +3738,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p,
else
client->prefixdel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/* re-add remote rmac if needed */
@@ -4863,8 +4858,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,
/*
* Handle message from client to delete a remote MACIP for a VNI.
*/
-int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS)
{
struct stream *s;
vni_t vni;
@@ -4884,9 +4878,9 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
memset(&ip, 0, sizeof(struct ipaddr));
memset(&vtep_ip, 0, sizeof(struct in_addr));
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote MACIP and process. */
/* Message contains VNI, followed by MAC followed by IP (if any)
* followed by remote VTEP IP.
@@ -5008,7 +5002,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
@@ -5016,8 +5010,7 @@ stream_failure:
* could be just the add of a MAC address or the add of a neighbor
* (IP+MAC).
*/
-int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS)
{
struct stream *s;
vni_t vni;
@@ -5045,12 +5038,12 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
zlog_warn(
"%s: EVPN Not turned on yet we have received a remote_macip add zapi callback",
__PRETTY_FUNCTION__);
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote MACIP and process. */
/* Message contains VNI, followed by MAC followed by IP (if any)
* followed by remote VTEP IP.
@@ -5159,7 +5152,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
prefix_mac2str(&macaddr, buf,
sizeof(buf)),
vni, inet_ntoa(vtep_ip));
- return -1;
+ return;
}
/* Is this MAC created for a MACIP? */
@@ -5212,7 +5205,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
prefix_mac2str(&macaddr, buf,
sizeof(buf)),
vni, inet_ntoa(vtep_ip));
- return -1;
+ return;
}
} else if (memcmp(&n->emac, &macaddr, sizeof(macaddr))
@@ -5240,7 +5233,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
@@ -5543,8 +5536,7 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
/*
* Handle message from client to delete a remote VTEP for a VNI.
*/
-int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)
{
struct stream *s;
u_short l = 0;
@@ -5559,18 +5551,18 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,
zlog_warn(
"%s: EVPN is not enabled yet we have received a vtep del command",
__PRETTY_FUNCTION__);
- return -1;
+ return;
}
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("Recv MACIP DEL for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote VTEP and process. */
STREAM_GETL(s, vni);
l += 4;
@@ -5623,14 +5615,13 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
* Handle message from client to add a remote VTEP for a VNI.
*/
-int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS)
{
struct stream *s;
u_short l = 0;
@@ -5644,18 +5635,18 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
zlog_warn(
"%s: EVPN not enabled yet we received a vtep_add zapi call",
__PRETTY_FUNCTION__);
- return -1;
+ return;
}
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("Recv MACIP ADD for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote VTEP and process. */
STREAM_GETL(s, vni);
l += 4;
@@ -5705,7 +5696,7 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
@@ -6512,8 +6503,7 @@ int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf)
* Handle message from client to enable/disable advertisement of g/w macip
* routes
*/
-int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS)
{
struct stream *s;
int advertise;
@@ -6527,19 +6517,19 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("EVPN GW-MACIP Adv for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
advertise = stream_getc(s);
vni = stream_get3(s);
zvni = zvni_lookup(vni);
if (!zvni)
- return 0;
+ return;
if (zvni->advertise_subnet == advertise)
- return 0;
+ return;
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("EVPN subnet Adv %s on VNI %d , currently %s",
@@ -6551,35 +6541,32 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,
ifp = zvni->vxlan_if;
if (!ifp)
- return 0;
+ return;
zif = ifp->info;
/* If down or not mapped to a bridge, we're done. */
if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
- return 0;
+ return;
zl2_info = zif->l2info.vxl;
vlan_if =
zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
if (!vlan_if)
- return 0;
+ return;
if (zvni->advertise_subnet)
zvni_advertise_subnet(zvni, vlan_if, 1);
else
zvni_advertise_subnet(zvni, vlan_if, 0);
-
- return 0;
}
/*
* Handle message from client to enable/disable advertisement of g/w macip
* routes
*/
-int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS)
{
struct stream *s;
int advertise;
@@ -6590,10 +6577,10 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("EVPN GW-MACIP Adv for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
STREAM_GETC(s, advertise);
STREAM_GET(&vni, s, 3);
@@ -6606,7 +6593,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
: "disabled");
if (zvrf->advertise_gw_macip == advertise)
- return 0;
+ return;
zvrf->advertise_gw_macip = advertise;
@@ -6625,7 +6612,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
zvni = zvni_lookup(vni);
if (!zvni)
- return 0;
+ return;
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
@@ -6635,26 +6622,26 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
: "disabled");
if (zvni->advertise_gw_macip == advertise)
- return 0;
+ return;
zvni->advertise_gw_macip = advertise;
ifp = zvni->vxlan_if;
if (!ifp)
- return 0;
+ return;
zif = ifp->info;
/* If down or not mapped to a bridge, we're done. */
if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
- return 0;
+ return;
zl2_info = zif->l2info.vxl;
vlan_if = zvni_map_to_svi(zl2_info.access_vlan,
zif->brslave_info.br_if);
if (!vlan_if)
- return 0;
+ return;
if (advertise_gw_macip_enabled(zvni)) {
/* Add primary SVI MAC-IP */
@@ -6676,7 +6663,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
@@ -6686,8 +6673,7 @@ stream_failure:
* when disabled, the entries should be deleted and remote VTEPs and MACs
* uninstalled from the kernel.
*/
-int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
{
struct stream *s = NULL;
int advertise = 0;
@@ -6695,10 +6681,10 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length,
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
STREAM_GETC(s, advertise);
if (IS_ZEBRA_DEBUG_VXLAN)
@@ -6707,7 +6693,7 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length,
is_evpn_enabled() ? "enabled" : "disabled");
if (zvrf->advertise_all_vni == advertise)
- return 0;
+ return;
zvrf->advertise_all_vni = advertise;
if (is_evpn_enabled()) {
@@ -6732,13 +6718,13 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length,
/* cleanup all l3vnis */
zns = zebra_ns_lookup(NS_DEFAULT);
if (!zns)
- return -1;
+ return;
hash_iterate(zns->l3vni_table, zl3vni_cleanup_all, NULL);
}
stream_failure:
- return 0;
+ return;
}
/*