Skip to content
Permalink
Browse files

Merge pull request #2888 from pguibert6WIND/misc_fix_static_tableid

Misc fix static tableid
  • Loading branch information...
donaldsharp committed Aug 22, 2018
2 parents 463e781 + 7a2c24d commit 46a67d25874b0634934c3b2b4dc50f53dc82a1fd
Showing with 23 additions and 22 deletions.
  1. +2 −1 bgpd/bgp_network.c
  2. +2 −1 lib/if.c
  3. +2 −4 lib/vrf.c
  4. +1 −1 lib/vrf.h
  5. +12 −12 staticd/static_vty.c
  6. +4 −3 staticd/static_zebra.c
@@ -672,7 +672,8 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,
listener->fd = sock;

/* this socket needs a change of ns. record bgp back pointer */
if (bgp->vrf_id != VRF_DEFAULT && vrf_is_mapped_on_netns(bgp->vrf_id))
if (bgp->vrf_id != VRF_DEFAULT && vrf_is_mapped_on_netns(
vrf_lookup_by_id(bgp->vrf_id)))
listener->bgp = bgp;

memcpy(&listener->su, sa, salen);
@@ -393,7 +393,8 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id, int vty)
* this should not be considered as an update
* then create the new interface
*/
if (ifp->vrf_id != vrf_id && vrf_is_mapped_on_netns(vrf_id))
if (ifp->vrf_id != vrf_id && vrf_is_mapped_on_netns(
vrf_lookup_by_id(vrf_id)))
return if_create(name, vrf_id);
/* If it came from the kernel
* or by way of zclient, believe it and update
@@ -682,10 +682,8 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname,
return CMD_SUCCESS;
}

int vrf_is_mapped_on_netns(vrf_id_t vrf_id)
int vrf_is_mapped_on_netns(struct vrf *vrf)
{
struct vrf *vrf = vrf_lookup_by_id(vrf_id);

if (!vrf || vrf->data.l.netns_name[0] == '\0')
return 0;
if (vrf->vrf_id == VRF_DEFAULT)
@@ -887,7 +885,7 @@ int vrf_bind(vrf_id_t vrf_id, int fd, char *name)

if (fd < 0 || name == NULL)
return fd;
if (vrf_is_mapped_on_netns(vrf_id))
if (vrf_is_mapped_on_netns(vrf_lookup_by_id(vrf_id)))
return fd;
#ifdef SO_BINDTODEVICE
ret = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name)+1);
@@ -237,7 +237,7 @@ extern vrf_id_t vrf_get_default_id(void);
#define VRF_DEFAULT vrf_get_default_id()

/* VRF is mapped on netns or not ? */
int vrf_is_mapped_on_netns(vrf_id_t vrf_id);
int vrf_is_mapped_on_netns(struct vrf *vrf);

/* VRF switch from NETNS */
extern int vrf_switch_to_netns(vrf_id_t vrf_id);
@@ -766,7 +766,7 @@ DEFPY(ip_route_blackhole,
"Table to configure\n"
"The table number to configure\n")
{
if (table_str && !vrf_is_backend_netns()) {
if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -805,7 +805,7 @@ DEFPY(ip_route_blackhole_vrf,
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct static_vrf *svrf = vrf->info;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && !vrf_is_mapped_on_netns(vrf)) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -868,7 +868,7 @@ DEFPY(ip_route_address_interface,
return CMD_WARNING_CONFIG_FAILED;
}

if (table_str && !vrf_is_backend_netns()) {
if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -924,7 +924,7 @@ DEFPY(ip_route_address_interface_vrf,
struct static_vrf *svrf = vrf->info;
struct static_vrf *nh_svrf;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && !vrf_is_mapped_on_netns(vrf)) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -984,7 +984,7 @@ DEFPY(ip_route,
struct static_vrf *nh_svrf;
const char *flag = NULL;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1049,7 +1049,7 @@ DEFPY(ip_route_vrf,
struct static_vrf *nh_svrf;
const char *flag = NULL;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && !vrf_is_mapped_on_netns(vrf)) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1104,7 +1104,7 @@ DEFPY(ipv6_route_blackhole,
"Table to configure\n"
"The table number to configure\n")
{
if (table_str && !vrf_is_backend_netns()) {
if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1144,7 +1144,7 @@ DEFPY(ipv6_route_blackhole_vrf,
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct static_vrf *svrf = vrf->info;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && !vrf_is_mapped_on_netns(vrf)) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1195,7 +1195,7 @@ DEFPY(ipv6_route_address_interface,
struct static_vrf *svrf;
struct static_vrf *nh_svrf;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1255,7 +1255,7 @@ DEFPY(ipv6_route_address_interface_vrf,
struct static_vrf *svrf = vrf->info;
struct static_vrf *nh_svrf;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && !vrf_is_mapped_on_netns(vrf)) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1309,7 +1309,7 @@ DEFPY(ipv6_route,
struct static_vrf *svrf;
struct static_vrf *nh_svrf;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1368,7 +1368,7 @@ DEFPY(ipv6_route_vrf,
struct static_vrf *svrf = vrf->info;
struct static_vrf *nh_svrf;

if (table_str && !vrf_is_backend_netns()) {
if (table_str && !vrf_is_mapped_on_netns(vrf)) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -273,9 +273,10 @@ extern void static_zebra_route_add(struct route_node *rn,
SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
api.tag = si_changed->tag;
}
api.tableid = si_changed->table_id;

zlog_debug("Distance sent down: %d %d", si_changed->distance, install);
if (si_changed->table_id != 0) {
SET_FLAG(api.message, ZAPI_MESSAGE_TABLEID);
api.tableid = si_changed->table_id;
}
for (/*loaded above*/; si; si = si->next) {
api_nh = &api.nexthops[nh_num];
if (si->nh_vrf_id == VRF_UNKNOWN)

0 comments on commit 46a67d2

Please sign in to comment.
You can’t perform that action at this time.