All of lore.kernel.org
 help / color / mirror / Atom feed
From: "R. Parameswaran" <parameswaran.r7@gmail.com>
To: netdev@vger.kernel.org
Cc: kleptog@svana.org, jchapman@katalix.com, davem@redhat.com,
	nprachan@brocade.com, rshearma@brocade.com,
	stephen@networkplumber.org, sdietric@brocade.com,
	ciwillia@brocade.com, lboccass@brocade.com, dfawcus@brocade.com,
	bhong@brocade.com, jblunck@brocade.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next v1 1/1] L2TP device MTU setup - tunnel socket needs a lock
Date: Tue, 11 Apr 2017 20:14:37 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.11.1704112010410.8819@nelson51.eng.vyatta.net> (raw)


The MTU overhead calculation in L2TP device set-up
merged via commit b784e7ebfce8cfb16c6f95e14e8532d0768ab7ff
needs to be adjusted to lock the tunnel socket while
referencing the sub-data structures to derive the
socket's IP overhead.
---
 include/linux/net.h | 2 +-
 net/l2tp/l2tp_eth.c | 2 ++
 net/socket.c        | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index a42fab2..abcfa46 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -298,7 +298,7 @@ int kernel_sendpage(struct socket *sock, struct page *page, int offset,
 int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg);
 int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how);
 
-/* Following routine returns the IP overhead imposed by a socket.  */
+/* Routine returns the IP overhead imposed by a (caller-protected) socket. */
 u32 kernel_sock_ip_overhead(struct sock *sk);
 
 #define MODULE_ALIAS_NETPROTO(proto) \
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 138566a..b722d55 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -225,7 +225,9 @@ static void l2tp_eth_adjust_mtu(struct l2tp_tunnel *tunnel,
 		dev->needed_headroom += session->hdr_len;
 		return;
 	}
+	lock_sock(tunnel->sock);
 	l3_overhead = kernel_sock_ip_overhead(tunnel->sock);
+	release_sock(tunnel->sock);
 	if (l3_overhead == 0) {
 		/* L3 Overhead couldn't be identified, this could be
 		 * because tunnel->sock was NULL or the socket's
diff --git a/net/socket.c b/net/socket.c
index eea9970..c2564eb 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -3360,7 +3360,7 @@ EXPORT_SYMBOL(kernel_sock_shutdown);
 /* This routine returns the IP overhead imposed by a socket i.e.
  * the length of the underlying IP header, depending on whether
  * this is an IPv4 or IPv6 socket and the length from IP options turned
- * on at the socket.
+ * on at the socket. Assumes that the caller has a lock on the socket.
  */
 u32 kernel_sock_ip_overhead(struct sock *sk)
 {
-- 
2.1.4

             reply	other threads:[~2017-04-12  3:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12  3:14 R. Parameswaran [this message]
2017-04-12  7:53 ` [PATCH net-next v1 1/1] L2TP device MTU setup - tunnel socket needs a lock Guillaume Nault
2017-04-12 20:42   ` R Parameswaran
2017-04-12 14:13 ` David Miller
2017-04-12 20:38   ` R Parameswaran

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=alpine.DEB.2.11.1704112010410.8819@nelson51.eng.vyatta.net \
    --to=parameswaran.r7@gmail.com \
    --cc=bhong@brocade.com \
    --cc=ciwillia@brocade.com \
    --cc=davem@redhat.com \
    --cc=dfawcus@brocade.com \
    --cc=jblunck@brocade.com \
    --cc=jchapman@katalix.com \
    --cc=kleptog@svana.org \
    --cc=lboccass@brocade.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nprachan@brocade.com \
    --cc=rshearma@brocade.com \
    --cc=sdietric@brocade.com \
    --cc=stephen@networkplumber.org \
    /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.