Skip to content
Permalink
Browse files

lib: change vrf_is_mapped_on_netns API

The function handles not a vrf pointer instead of a vrf_id value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
  • Loading branch information...
pguibert6WIND committed Aug 22, 2018
1 parent 5ab5e41 commit 3d4c0b49dacb454dbcf4dc3b56f8ccd8bb5202e5
Showing with 7 additions and 7 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
@@ -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);

0 comments on commit 3d4c0b4

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.