Commit 49b4994c authored by David Herrmann's avatar David Herrmann Committed by David S. Miller

net/ipv6/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: default avatarTom Gundersen <teg@jklm.no>
Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2eadee72
...@@ -32,18 +32,9 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg, ...@@ -32,18 +32,9 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
goto error; goto error;
} }
if (cfg->bind_ifindex) { if (cfg->bind_ifindex) {
struct net_device *dev; err = kernel_setsockopt(sock, SOL_SOCKET, SO_BINDTOIFINDEX,
(void *)&cfg->bind_ifindex,
dev = dev_get_by_index(net, cfg->bind_ifindex); sizeof(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);
if (err < 0) if (err < 0)
goto error; goto error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment