Merge pull request #5586 from ton31337/fix/bgp_name_in_views_7.1

lib: [7.1] perform a bind inside vrf_socket() call
This commit is contained in:
Quentin Young 2020-01-14 01:40:28 -05:00 committed by GitHub
commit 14c56d646c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);