mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-25 09:10:57 +00:00
lib: perform a bind inside vrf_socket() call
This is an extension to previous behavior, where the bind() operation was performed only when vrf was not a netns backend kind. This was done like that because usually the bind parameter is the vrf name itself, and having an interface name with vrf name is an expectation so that the bind operation works. the bind() operation can be performed on whatever device provided that that name is not null and there is an interface in the vrf that has the same name as the parameter. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
c785c0516e
commit
a06437e632
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user