From eea45da4036d6d2dc3b7d2f870a0892b72aeeba4 Mon Sep 17 00:00:00 2001 From: Taehee Yoo Date: Sun, 8 Mar 2020 01:19:07 +0000 Subject: [PATCH 1/3] bareudp: add module alias In the current bareudp code, there is no module alias. So, RTNL couldn't load bareudp module automatically. Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller --- drivers/net/bareudp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index 15337e9d4fad..b1210b516137 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -801,6 +801,7 @@ static void __exit bareudp_cleanup_module(void) } module_exit(bareudp_cleanup_module); +MODULE_ALIAS_RTNL_LINK("bareudp"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Martin Varghese "); MODULE_DESCRIPTION("Interface driver for UDP encapsulated traffic"); From c46a49a45c865350d6051df555034b86a2ac72ff Mon Sep 17 00:00:00 2001 From: Taehee Yoo Date: Sun, 8 Mar 2020 01:19:17 +0000 Subject: [PATCH 2/3] bareudp: print error message when command fails When bareudp netlink command fails, it doesn't print any error message. So, users couldn't know the exact reason. In order to tell the exact reason to the user, the extack error message is used in this patch. Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller --- drivers/net/bareudp.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index b1210b516137..c9d0d68467f7 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -556,10 +556,17 @@ static int bareudp_validate(struct nlattr *tb[], struct nlattr *data[], return 0; } -static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf) +static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf, + struct netlink_ext_ack *extack) { - if (!data[IFLA_BAREUDP_PORT] || !data[IFLA_BAREUDP_ETHERTYPE]) + if (!data[IFLA_BAREUDP_PORT]) { + NL_SET_ERR_MSG(extack, "port not specified"); return -EINVAL; + } + if (!data[IFLA_BAREUDP_ETHERTYPE]) { + NL_SET_ERR_MSG(extack, "ethertype not specified"); + return -EINVAL; + } if (data[IFLA_BAREUDP_PORT]) conf->port = nla_get_u16(data[IFLA_BAREUDP_PORT]); @@ -635,7 +642,7 @@ static int bareudp_newlink(struct net *net, struct net_device *dev, struct bareudp_conf conf; int err; - err = bareudp2info(data, &conf); + err = bareudp2info(data, &conf, extack); if (err) return err; From 2baecda37f4ef4414be15452a333fe4fd13c0df3 Mon Sep 17 00:00:00 2001 From: Taehee Yoo Date: Sun, 8 Mar 2020 01:19:30 +0000 Subject: [PATCH 3/3] bareudp: remove unnecessary udp_encap_enable() in bareudp_socket_create() In the current code, udp_encap_enable() is called in bareudp_socket_create(). But, setup_udp_tunnel_sock() internally calls udp_encap_enable(). So, udp_encap_enable() is unnecessary. Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller --- drivers/net/bareudp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index c9d0d68467f7..71a2f480f70e 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -250,9 +250,6 @@ static int bareudp_socket_create(struct bareudp_dev *bareudp, __be16 port) tunnel_cfg.encap_destroy = NULL; setup_udp_tunnel_sock(bareudp->net, sock, &tunnel_cfg); - if (sock->sk->sk_family == AF_INET6) - udp_encap_enable(); - rcu_assign_pointer(bareudp->sock, sock); return 0; }