diff mbox series

[net-next,1/6] l2tp: add netlink info to session create callback

Message ID 20200930210707.10717-2-tparkin@katalix.com
State New
Headers show
Series l2tp: add ac/pppoe driver | expand

Commit Message

Tom Parkin Sept. 30, 2020, 9:07 p.m. UTC
To support creating different types of pseudowire, l2tp's netlink
commands for session create and destroy are implemented using callbacks
into pseudowire-specific code.

The pseudowire types implemented so far (PPP and Ethernet) use common
parameters which are extracted by l2tp_netlink into a session
configuration structure.

Different pseudowires may require different parameters: rather than
adding these to the common configuration structure, make the netlink
info visible to the pseudowire code so that it can perform its own
validation of the extra attributes it requires.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
---
 net/l2tp/l2tp_core.h    | 4 +++-
 net/l2tp/l2tp_eth.c     | 3 ++-
 net/l2tp/l2tp_netlink.c | 3 ++-
 net/l2tp/l2tp_ppp.c     | 3 ++-
 4 files changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
index cb21d906343e..bd62a3e2c98d 100644
--- a/net/l2tp/l2tp_core.h
+++ b/net/l2tp/l2tp_core.h
@@ -10,6 +10,7 @@ 
 
 #include <net/dst.h>
 #include <net/sock.h>
+#include <net/genetlink.h>
 
 #ifdef CONFIG_XFRM
 #include <net/xfrm.h>
@@ -196,7 +197,8 @@  struct l2tp_nl_cmd_ops {
 	 */
 	int (*session_create)(struct net *net, struct l2tp_tunnel *tunnel,
 			      u32 session_id, u32 peer_session_id,
-			      struct l2tp_session_cfg *cfg);
+			      struct l2tp_session_cfg *cfg,
+			      struct genl_info *info);
 
 	/* The pseudowire session delete callback is responsible for initiating the deletion
 	 * of a session instance.
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 6cd97c75445c..b2545e699174 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -243,7 +243,8 @@  static void l2tp_eth_adjust_mtu(struct l2tp_tunnel *tunnel,
 
 static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
 			   u32 session_id, u32 peer_session_id,
-			   struct l2tp_session_cfg *cfg)
+			   struct l2tp_session_cfg *cfg,
+			   struct genl_info *info)
 {
 	unsigned char name_assign_type;
 	struct net_device *dev;
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 5ca5056e9636..7045eb105e6a 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -629,7 +629,8 @@  static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
 	ret = l2tp_nl_cmd_ops[cfg.pw_type]->session_create(net, tunnel,
 							   session_id,
 							   peer_session_id,
-							   &cfg);
+							   &cfg,
+							   info);
 
 	if (ret >= 0) {
 		session = l2tp_tunnel_get_session(tunnel, session_id);
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index aea85f91f059..a2f7896d047e 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -853,7 +853,8 @@  static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
 /* Called when creating sessions via the netlink interface. */
 static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel,
 				   u32 session_id, u32 peer_session_id,
-				   struct l2tp_session_cfg *cfg)
+				   struct l2tp_session_cfg *cfg,
+				   struct genl_info *info)
 {
 	int error;
 	struct l2tp_session *session;