Skip to content

Commit

Permalink
Merge pull request #5586 from ton31337/fix/bgp_name_in_views_7.1
Browse files Browse the repository at this point in the history
lib: [7.1] perform a bind inside vrf_socket() call
  • Loading branch information
qlyoung committed Jan 14, 2020
2 parents c785c05 + a06437e commit 14c56d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,16 @@ vrf_id_t vrf_get_default_id(void)
int vrf_bind(vrf_id_t vrf_id, int fd, const char *name)
{
int ret = 0;
struct interface *ifp;

if (fd < 0 || name == NULL)
return fd;
if (vrf_is_backend_netns())
/* the device should exist
* otherwise we should return
* case ifname = vrf in netns mode => return
*/
ifp = if_lookup_by_name(name, vrf_id);
if (!ifp)
return fd;
#ifdef SO_BINDTODEVICE
ret = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name)+1);
Expand Down

0 comments on commit 14c56d6

Please sign in to comment.