From: David Herrmann <dh.herrmann@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, teg@jklm.no, David Herrmann <dh.herrmann@gmail.com>
Subject: [PATCH 2/3] net/ipv4/udp_tunnel: prefer SO_BINDTOIF over SO_BINDTODEVICE
Date: Thu, 10 Jan 2019 15:25:28 +0100 [thread overview]
Message-ID: <20190110142529.14315-2-dh.herrmann@gmail.com> (raw)
In-Reply-To: <20190110142529.14315-1-dh.herrmann@gmail.com>
The udp-tunnel setup allows binding sockets to a network device. Prefer
the new SO_BINDTOIF to avoid temporarily resolving the device-name just
to look it up in the ioctl again.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
net/ipv4/udp_tunnel.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c
index be8b5b2157d8..5d26c501da3b 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_BINDTOIF,
+ (void *)&cfg->bind_ifindex,
+ sizeof(cfg->bind_ifindex));
if (err < 0)
goto error;
}
--
2.20.1
next prev parent reply other threads:[~2019-01-10 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 14:25 [PATCH 1/3] net: introduce SO_BINDTOIF sockopt David Herrmann
2019-01-10 14:25 ` David Herrmann [this message]
2019-01-10 14:40 ` [PATCH 2/3] net/ipv4/udp_tunnel: prefer SO_BINDTOIF over SO_BINDTODEVICE Tom Gundersen
2019-01-10 14:25 ` [PATCH 3/3] net/ipv6/udp_tunnel: " David Herrmann
2019-01-10 14:41 ` Tom Gundersen
2019-01-10 14:39 ` [PATCH 1/3] net: introduce SO_BINDTOIF sockopt Tom Gundersen
2019-01-10 16:38 ` David Ahern
2019-01-10 16:39 ` Roopa Prabhu
2019-01-10 16:50 ` David Herrmann
2019-01-13 20:09 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190110142529.14315-2-dh.herrmann@gmail.com \
--to=dh.herrmann@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=teg@jklm.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.