diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2019-01-15 14:42:15 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-01-17 14:55:52 -0800 |
commit | 2eadee72dbb8de37585a1ee63823c8495454ffa4 (patch) | |
tree | 0684471890b3c11f637d78603dfd9a13880fabb4 /net/ipv4/udp_tunnel.c | |
parent | f5dd3d0c9638a9d9a02b5964c4ad636f06cf7e2c (diff) | |
download | linux-stable-2eadee72dbb8de37585a1ee63823c8495454ffa4.tar.gz linux-stable-2eadee72dbb8de37585a1ee63823c8495454ffa4.tar.bz2 linux-stable-2eadee72dbb8de37585a1ee63823c8495454ffa4.zip |
net/ipv4/udp_tunnel: prefer SO_BINDTOIFINDEX over SO_BINDTODEVICE
The udp-tunnel setup allows binding sockets to a network device. Prefer
the new SO_BINDTOIFINDEX to avoid temporarily resolving the device-name
just to look it up in the ioctl again.
Reviewed-by: Tom Gundersen <teg@jklm.no>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp_tunnel.c')
-rw-r--r-- | net/ipv4/udp_tunnel.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c index be8b5b2157d8..e93cc0379201 100644 --- a/net/ipv4/udp_tunnel.c +++ b/net/ipv4/udp_tunnel.c @@ -21,18 +21,9 @@ int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg, goto error; if (cfg->bind_ifindex) { - struct net_device *dev; - - dev = dev_get_by_index(net, cfg->bind_ifindex); - if (!dev) { - err = -ENODEV; - goto error; - } - - err = kernel_setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, - dev->name, strlen(dev->name) + 1); - dev_put(dev); - + err = kernel_setsockopt(sock, SOL_SOCKET, SO_BINDTOIFINDEX, + (void *)&cfg->bind_ifindex, + sizeof(cfg->bind_ifindex)); if (err < 0) goto error; } |