Commit 117aef12 authored by Alexander Lobakin's avatar Alexander Lobakin Committed by David S. Miller

ip_tunnel: use a separate struct to store tunnel params in the kernel

Unlike IPv6 tunnels which use purely-kernel __ip6_tnl_parm structure
to store params inside the kernel, IPv4 tunnel code uses the same
ip_tunnel_parm which is being used to talk with the userspace.
This makes it difficult to alter or add any fields or use a
different format for whatever data.
Define struct ip_tunnel_parm_kern, a 1:1 copy of ip_tunnel_parm for
now, and use it throughout the code. Define the pieces, where the copy
user <-> kernel happens, as standalone functions, and copy the data
there field-by-field, so that the kernel-side structure could be easily
modified later on and the users wouldn't have to care about this.
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarAlexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7adaf37f
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "spectrum_ipip.h" #include "spectrum_ipip.h"
#include "reg.h" #include "reg.h"
struct ip_tunnel_parm struct ip_tunnel_parm_kern
mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev) mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev)
{ {
struct ip_tunnel *tun = netdev_priv(ol_dev); struct ip_tunnel *tun = netdev_priv(ol_dev);
...@@ -24,7 +24,8 @@ mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev) ...@@ -24,7 +24,8 @@ mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev)
return tun->parms; return tun->parms;
} }
static bool mlxsw_sp_ipip_parms4_has_ikey(const struct ip_tunnel_parm *parms) static bool
mlxsw_sp_ipip_parms4_has_ikey(const struct ip_tunnel_parm_kern *parms)
{ {
return !!(parms->i_flags & TUNNEL_KEY); return !!(parms->i_flags & TUNNEL_KEY);
} }
...@@ -34,7 +35,8 @@ static bool mlxsw_sp_ipip_parms6_has_ikey(const struct __ip6_tnl_parm *parms) ...@@ -34,7 +35,8 @@ static bool mlxsw_sp_ipip_parms6_has_ikey(const struct __ip6_tnl_parm *parms)
return !!(parms->i_flags & TUNNEL_KEY); return !!(parms->i_flags & TUNNEL_KEY);
} }
static bool mlxsw_sp_ipip_parms4_has_okey(const struct ip_tunnel_parm *parms) static bool
mlxsw_sp_ipip_parms4_has_okey(const struct ip_tunnel_parm_kern *parms)
{ {
return !!(parms->o_flags & TUNNEL_KEY); return !!(parms->o_flags & TUNNEL_KEY);
} }
...@@ -44,7 +46,7 @@ static bool mlxsw_sp_ipip_parms6_has_okey(const struct __ip6_tnl_parm *parms) ...@@ -44,7 +46,7 @@ static bool mlxsw_sp_ipip_parms6_has_okey(const struct __ip6_tnl_parm *parms)
return !!(parms->o_flags & TUNNEL_KEY); return !!(parms->o_flags & TUNNEL_KEY);
} }
static u32 mlxsw_sp_ipip_parms4_ikey(const struct ip_tunnel_parm *parms) static u32 mlxsw_sp_ipip_parms4_ikey(const struct ip_tunnel_parm_kern *parms)
{ {
return mlxsw_sp_ipip_parms4_has_ikey(parms) ? return mlxsw_sp_ipip_parms4_has_ikey(parms) ?
be32_to_cpu(parms->i_key) : 0; be32_to_cpu(parms->i_key) : 0;
...@@ -56,7 +58,7 @@ static u32 mlxsw_sp_ipip_parms6_ikey(const struct __ip6_tnl_parm *parms) ...@@ -56,7 +58,7 @@ static u32 mlxsw_sp_ipip_parms6_ikey(const struct __ip6_tnl_parm *parms)
be32_to_cpu(parms->i_key) : 0; be32_to_cpu(parms->i_key) : 0;
} }
static u32 mlxsw_sp_ipip_parms4_okey(const struct ip_tunnel_parm *parms) static u32 mlxsw_sp_ipip_parms4_okey(const struct ip_tunnel_parm_kern *parms)
{ {
return mlxsw_sp_ipip_parms4_has_okey(parms) ? return mlxsw_sp_ipip_parms4_has_okey(parms) ?
be32_to_cpu(parms->o_key) : 0; be32_to_cpu(parms->o_key) : 0;
...@@ -69,7 +71,7 @@ static u32 mlxsw_sp_ipip_parms6_okey(const struct __ip6_tnl_parm *parms) ...@@ -69,7 +71,7 @@ static u32 mlxsw_sp_ipip_parms6_okey(const struct __ip6_tnl_parm *parms)
} }
static union mlxsw_sp_l3addr static union mlxsw_sp_l3addr
mlxsw_sp_ipip_parms4_saddr(const struct ip_tunnel_parm *parms) mlxsw_sp_ipip_parms4_saddr(const struct ip_tunnel_parm_kern *parms)
{ {
return (union mlxsw_sp_l3addr) { .addr4 = parms->iph.saddr }; return (union mlxsw_sp_l3addr) { .addr4 = parms->iph.saddr };
} }
...@@ -81,7 +83,7 @@ mlxsw_sp_ipip_parms6_saddr(const struct __ip6_tnl_parm *parms) ...@@ -81,7 +83,7 @@ mlxsw_sp_ipip_parms6_saddr(const struct __ip6_tnl_parm *parms)
} }
static union mlxsw_sp_l3addr static union mlxsw_sp_l3addr
mlxsw_sp_ipip_parms4_daddr(const struct ip_tunnel_parm *parms) mlxsw_sp_ipip_parms4_daddr(const struct ip_tunnel_parm_kern *parms)
{ {
return (union mlxsw_sp_l3addr) { .addr4 = parms->iph.daddr }; return (union mlxsw_sp_l3addr) { .addr4 = parms->iph.daddr };
} }
...@@ -96,7 +98,7 @@ union mlxsw_sp_l3addr ...@@ -96,7 +98,7 @@ union mlxsw_sp_l3addr
mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto, mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,
const struct net_device *ol_dev) const struct net_device *ol_dev)
{ {
struct ip_tunnel_parm parms4; struct ip_tunnel_parm_kern parms4;
struct __ip6_tnl_parm parms6; struct __ip6_tnl_parm parms6;
switch (proto) { switch (proto) {
...@@ -115,7 +117,9 @@ mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto, ...@@ -115,7 +117,9 @@ mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,
static __be32 mlxsw_sp_ipip_netdev_daddr4(const struct net_device *ol_dev) static __be32 mlxsw_sp_ipip_netdev_daddr4(const struct net_device *ol_dev)
{ {
struct ip_tunnel_parm parms4 = mlxsw_sp_ipip_netdev_parms4(ol_dev); struct ip_tunnel_parm_kern parms4;
parms4 = mlxsw_sp_ipip_netdev_parms4(ol_dev);
return mlxsw_sp_ipip_parms4_daddr(&parms4).addr4; return mlxsw_sp_ipip_parms4_daddr(&parms4).addr4;
} }
...@@ -124,7 +128,7 @@ static union mlxsw_sp_l3addr ...@@ -124,7 +128,7 @@ static union mlxsw_sp_l3addr
mlxsw_sp_ipip_netdev_daddr(enum mlxsw_sp_l3proto proto, mlxsw_sp_ipip_netdev_daddr(enum mlxsw_sp_l3proto proto,
const struct net_device *ol_dev) const struct net_device *ol_dev)
{ {
struct ip_tunnel_parm parms4; struct ip_tunnel_parm_kern parms4;
struct __ip6_tnl_parm parms6; struct __ip6_tnl_parm parms6;
switch (proto) { switch (proto) {
...@@ -150,7 +154,7 @@ bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr) ...@@ -150,7 +154,7 @@ bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr)
static struct mlxsw_sp_ipip_parms static struct mlxsw_sp_ipip_parms
mlxsw_sp_ipip_netdev_parms_init_gre4(const struct net_device *ol_dev) mlxsw_sp_ipip_netdev_parms_init_gre4(const struct net_device *ol_dev)
{ {
struct ip_tunnel_parm parms = mlxsw_sp_ipip_netdev_parms4(ol_dev); struct ip_tunnel_parm_kern parms = mlxsw_sp_ipip_netdev_parms4(ol_dev);
return (struct mlxsw_sp_ipip_parms) { return (struct mlxsw_sp_ipip_parms) {
.proto = MLXSW_SP_L3_PROTO_IPV4, .proto = MLXSW_SP_L3_PROTO_IPV4,
...@@ -187,8 +191,8 @@ mlxsw_sp_ipip_decap_config_gre4(struct mlxsw_sp *mlxsw_sp, ...@@ -187,8 +191,8 @@ mlxsw_sp_ipip_decap_config_gre4(struct mlxsw_sp *mlxsw_sp,
{ {
u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb); u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb);
u16 ul_rif_id = mlxsw_sp_ipip_lb_ul_rif_id(ipip_entry->ol_lb); u16 ul_rif_id = mlxsw_sp_ipip_lb_ul_rif_id(ipip_entry->ol_lb);
struct ip_tunnel_parm_kern parms;
char rtdp_pl[MLXSW_REG_RTDP_LEN]; char rtdp_pl[MLXSW_REG_RTDP_LEN];
struct ip_tunnel_parm parms;
unsigned int type_check; unsigned int type_check;
bool has_ikey; bool has_ikey;
u32 daddr4; u32 daddr4;
...@@ -252,7 +256,7 @@ static struct mlxsw_sp_rif_ipip_lb_config ...@@ -252,7 +256,7 @@ static struct mlxsw_sp_rif_ipip_lb_config
mlxsw_sp_ipip_ol_loopback_config_gre4(struct mlxsw_sp *mlxsw_sp, mlxsw_sp_ipip_ol_loopback_config_gre4(struct mlxsw_sp *mlxsw_sp,
const struct net_device *ol_dev) const struct net_device *ol_dev)
{ {
struct ip_tunnel_parm parms = mlxsw_sp_ipip_netdev_parms4(ol_dev); struct ip_tunnel_parm_kern parms = mlxsw_sp_ipip_netdev_parms4(ol_dev);
enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt; enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt;
lb_ipipt = mlxsw_sp_ipip_parms4_has_okey(&parms) ? lb_ipipt = mlxsw_sp_ipip_parms4_has_okey(&parms) ?
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <linux/if_tunnel.h> #include <linux/if_tunnel.h>
#include <net/ip6_tunnel.h> #include <net/ip6_tunnel.h>
struct ip_tunnel_parm struct ip_tunnel_parm_kern
mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev); mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev);
struct __ip6_tnl_parm struct __ip6_tnl_parm
mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev); mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev);
......
...@@ -413,8 +413,8 @@ mlxsw_sp_span_gretap4_route(const struct net_device *to_dev, ...@@ -413,8 +413,8 @@ mlxsw_sp_span_gretap4_route(const struct net_device *to_dev,
__be32 *saddrp, __be32 *daddrp) __be32 *saddrp, __be32 *daddrp)
{ {
struct ip_tunnel *tun = netdev_priv(to_dev); struct ip_tunnel *tun = netdev_priv(to_dev);
struct ip_tunnel_parm_kern parms;
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct ip_tunnel_parm parms;
struct rtable *rt = NULL; struct rtable *rt = NULL;
struct flowi4 fl4; struct flowi4 fl4;
...@@ -451,7 +451,7 @@ mlxsw_sp_span_entry_gretap4_parms(struct mlxsw_sp *mlxsw_sp, ...@@ -451,7 +451,7 @@ mlxsw_sp_span_entry_gretap4_parms(struct mlxsw_sp *mlxsw_sp,
const struct net_device *to_dev, const struct net_device *to_dev,
struct mlxsw_sp_span_parms *sparmsp) struct mlxsw_sp_span_parms *sparmsp)
{ {
struct ip_tunnel_parm tparm = mlxsw_sp_ipip_netdev_parms4(to_dev); struct ip_tunnel_parm_kern tparm = mlxsw_sp_ipip_netdev_parms4(to_dev);
union mlxsw_sp_l3addr saddr = { .addr4 = tparm.iph.saddr }; union mlxsw_sp_l3addr saddr = { .addr4 = tparm.iph.saddr };
union mlxsw_sp_l3addr daddr = { .addr4 = tparm.iph.daddr }; union mlxsw_sp_l3addr daddr = { .addr4 = tparm.iph.daddr };
bool inherit_tos = tparm.iph.tos & 0x1; bool inherit_tos = tparm.iph.tos & 0x1;
......
...@@ -59,7 +59,7 @@ struct ethtool_ops; ...@@ -59,7 +59,7 @@ struct ethtool_ops;
struct kernel_hwtstamp_config; struct kernel_hwtstamp_config;
struct phy_device; struct phy_device;
struct dsa_port; struct dsa_port;
struct ip_tunnel_parm; struct ip_tunnel_parm_kern;
struct macsec_context; struct macsec_context;
struct macsec_ops; struct macsec_ops;
struct netdev_name_node; struct netdev_name_node;
...@@ -1327,7 +1327,7 @@ struct netdev_net_notifier { ...@@ -1327,7 +1327,7 @@ struct netdev_net_notifier {
* queue id bound to an AF_XDP socket. The flags field specifies if * queue id bound to an AF_XDP socket. The flags field specifies if
* only RX, only Tx, or both should be woken up using the flags * only RX, only Tx, or both should be woken up using the flags
* XDP_WAKEUP_RX and XDP_WAKEUP_TX. * XDP_WAKEUP_RX and XDP_WAKEUP_TX.
* int (*ndo_tunnel_ctl)(struct net_device *dev, struct ip_tunnel_parm *p, * int (*ndo_tunnel_ctl)(struct net_device *dev, struct ip_tunnel_parm_kern *p,
* int cmd); * int cmd);
* Add, change, delete or get information on an IPv4 tunnel. * Add, change, delete or get information on an IPv4 tunnel.
* struct net_device *(*ndo_get_peer_dev)(struct net_device *dev); * struct net_device *(*ndo_get_peer_dev)(struct net_device *dev);
...@@ -1583,7 +1583,8 @@ struct net_device_ops { ...@@ -1583,7 +1583,8 @@ struct net_device_ops {
int (*ndo_xsk_wakeup)(struct net_device *dev, int (*ndo_xsk_wakeup)(struct net_device *dev,
u32 queue_id, u32 flags); u32 queue_id, u32 flags);
int (*ndo_tunnel_ctl)(struct net_device *dev, int (*ndo_tunnel_ctl)(struct net_device *dev,
struct ip_tunnel_parm *p, int cmd); struct ip_tunnel_parm_kern *p,
int cmd);
struct net_device * (*ndo_get_peer_dev)(struct net_device *dev); struct net_device * (*ndo_get_peer_dev)(struct net_device *dev);
int (*ndo_fill_forward_path)(struct net_device_path_ctx *ctx, int (*ndo_fill_forward_path)(struct net_device_path_ctx *ctx,
struct net_device_path *path); struct net_device_path *path);
......
...@@ -110,6 +110,17 @@ struct ip_tunnel_prl_entry { ...@@ -110,6 +110,17 @@ struct ip_tunnel_prl_entry {
struct metadata_dst; struct metadata_dst;
/* Kernel-side copy of ip_tunnel_parm */
struct ip_tunnel_parm_kern {
char name[IFNAMSIZ];
int link;
__be16 i_flags;
__be16 o_flags;
__be32 i_key;
__be32 o_key;
struct iphdr iph;
};
struct ip_tunnel { struct ip_tunnel {
struct ip_tunnel __rcu *next; struct ip_tunnel __rcu *next;
struct hlist_node hash_node; struct hlist_node hash_node;
...@@ -136,7 +147,7 @@ struct ip_tunnel { ...@@ -136,7 +147,7 @@ struct ip_tunnel {
struct dst_cache dst_cache; struct dst_cache dst_cache;
struct ip_tunnel_parm parms; struct ip_tunnel_parm_kern parms;
int mlink; int mlink;
int encap_hlen; /* Encap header length (FOU,GUE) */ int encap_hlen; /* Encap header length (FOU,GUE) */
...@@ -291,7 +302,11 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, ...@@ -291,7 +302,11 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
const struct iphdr *tnl_params, const u8 protocol); const struct iphdr *tnl_params, const u8 protocol);
void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
const u8 proto, int tunnel_hlen); const u8 proto, int tunnel_hlen);
int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd); int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p,
int cmd);
bool ip_tunnel_parm_from_user(struct ip_tunnel_parm_kern *kp,
const void __user *data);
bool ip_tunnel_parm_to_user(void __user *data, struct ip_tunnel_parm_kern *kp);
int ip_tunnel_siocdevprivate(struct net_device *dev, struct ifreq *ifr, int ip_tunnel_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
void __user *data, int cmd); void __user *data, int cmd);
int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict); int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict);
...@@ -307,16 +322,16 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, ...@@ -307,16 +322,16 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst, const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,
bool log_ecn_error); bool log_ecn_error);
int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[], int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[],
struct ip_tunnel_parm *p, __u32 fwmark); struct ip_tunnel_parm_kern *p, __u32 fwmark);
int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
struct ip_tunnel_parm *p, __u32 fwmark); struct ip_tunnel_parm_kern *p, __u32 fwmark);
void ip_tunnel_setup(struct net_device *dev, unsigned int net_id); void ip_tunnel_setup(struct net_device *dev, unsigned int net_id);
bool ip_tunnel_netlink_encap_parms(struct nlattr *data[], bool ip_tunnel_netlink_encap_parms(struct nlattr *data[],
struct ip_tunnel_encap *encap); struct ip_tunnel_encap *encap);
void ip_tunnel_netlink_parms(struct nlattr *data[], void ip_tunnel_netlink_parms(struct nlattr *data[],
struct ip_tunnel_parm *parms); struct ip_tunnel_parm_kern *parms);
extern const struct header_ops ip_tunnel_header_ops; extern const struct header_ops ip_tunnel_header_ops;
__be16 ip_tunnel_parse_protocol(const struct sk_buff *skb); __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
......
...@@ -785,7 +785,8 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu) ...@@ -785,7 +785,8 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu)
} }
} }
static int ipgre_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, static int ipgre_tunnel_ctl(struct net_device *dev,
struct ip_tunnel_parm_kern *p,
int cmd) int cmd)
{ {
int err; int err;
...@@ -1131,7 +1132,7 @@ static int erspan_validate(struct nlattr *tb[], struct nlattr *data[], ...@@ -1131,7 +1132,7 @@ static int erspan_validate(struct nlattr *tb[], struct nlattr *data[],
static int ipgre_netlink_parms(struct net_device *dev, static int ipgre_netlink_parms(struct net_device *dev,
struct nlattr *data[], struct nlattr *data[],
struct nlattr *tb[], struct nlattr *tb[],
struct ip_tunnel_parm *parms, struct ip_tunnel_parm_kern *parms,
__u32 *fwmark) __u32 *fwmark)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
...@@ -1198,7 +1199,7 @@ static int ipgre_netlink_parms(struct net_device *dev, ...@@ -1198,7 +1199,7 @@ static int ipgre_netlink_parms(struct net_device *dev,
static int erspan_netlink_parms(struct net_device *dev, static int erspan_netlink_parms(struct net_device *dev,
struct nlattr *data[], struct nlattr *data[],
struct nlattr *tb[], struct nlattr *tb[],
struct ip_tunnel_parm *parms, struct ip_tunnel_parm_kern *parms,
__u32 *fwmark) __u32 *fwmark)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
...@@ -1357,7 +1358,7 @@ static int ipgre_newlink(struct net *src_net, struct net_device *dev, ...@@ -1357,7 +1358,7 @@ static int ipgre_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[], struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel_parm p; struct ip_tunnel_parm_kern p;
__u32 fwmark = 0; __u32 fwmark = 0;
int err; int err;
...@@ -1375,7 +1376,7 @@ static int erspan_newlink(struct net *src_net, struct net_device *dev, ...@@ -1375,7 +1376,7 @@ static int erspan_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[], struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel_parm p; struct ip_tunnel_parm_kern p;
__u32 fwmark = 0; __u32 fwmark = 0;
int err; int err;
...@@ -1394,8 +1395,8 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -1394,8 +1395,8 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm_kern p;
__u32 fwmark = t->fwmark; __u32 fwmark = t->fwmark;
struct ip_tunnel_parm p;
int err; int err;
err = ipgre_newlink_encap_setup(dev, data); err = ipgre_newlink_encap_setup(dev, data);
...@@ -1423,8 +1424,8 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -1423,8 +1424,8 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm_kern p;
__u32 fwmark = t->fwmark; __u32 fwmark = t->fwmark;
struct ip_tunnel_parm p;
int err; int err;
err = ipgre_newlink_encap_setup(dev, data); err = ipgre_newlink_encap_setup(dev, data);
...@@ -1496,7 +1497,7 @@ static size_t ipgre_get_size(const struct net_device *dev) ...@@ -1496,7 +1497,7 @@ static size_t ipgre_get_size(const struct net_device *dev)
static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev) static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm *p = &t->parms; struct ip_tunnel_parm_kern *p = &t->parms;
__be16 o_flags = p->o_flags; __be16 o_flags = p->o_flags;
if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
......
...@@ -56,7 +56,7 @@ static unsigned int ip_tunnel_hash(__be32 key, __be32 remote) ...@@ -56,7 +56,7 @@ static unsigned int ip_tunnel_hash(__be32 key, __be32 remote)
IP_TNL_HASH_BITS); IP_TNL_HASH_BITS);
} }
static bool ip_tunnel_key_match(const struct ip_tunnel_parm *p, static bool ip_tunnel_key_match(const struct ip_tunnel_parm_kern *p,
__be16 flags, __be32 key) __be16 flags, __be32 key)
{ {
if (p->i_flags & TUNNEL_KEY) { if (p->i_flags & TUNNEL_KEY) {
...@@ -171,7 +171,7 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, ...@@ -171,7 +171,7 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn,
EXPORT_SYMBOL_GPL(ip_tunnel_lookup); EXPORT_SYMBOL_GPL(ip_tunnel_lookup);
static struct hlist_head *ip_bucket(struct ip_tunnel_net *itn, static struct hlist_head *ip_bucket(struct ip_tunnel_net *itn,
struct ip_tunnel_parm *parms) struct ip_tunnel_parm_kern *parms)
{ {
unsigned int h; unsigned int h;
__be32 remote; __be32 remote;
...@@ -206,7 +206,7 @@ static void ip_tunnel_del(struct ip_tunnel_net *itn, struct ip_tunnel *t) ...@@ -206,7 +206,7 @@ static void ip_tunnel_del(struct ip_tunnel_net *itn, struct ip_tunnel *t)
} }
static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn, static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn,
struct ip_tunnel_parm *parms, struct ip_tunnel_parm_kern *parms,
int type) int type)
{ {
__be32 remote = parms->iph.daddr; __be32 remote = parms->iph.daddr;
...@@ -230,7 +230,7 @@ static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn, ...@@ -230,7 +230,7 @@ static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn,
static struct net_device *__ip_tunnel_create(struct net *net, static struct net_device *__ip_tunnel_create(struct net *net,
const struct rtnl_link_ops *ops, const struct rtnl_link_ops *ops,
struct ip_tunnel_parm *parms) struct ip_tunnel_parm_kern *parms)
{ {
int err; int err;
struct ip_tunnel *tunnel; struct ip_tunnel *tunnel;
...@@ -326,7 +326,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev) ...@@ -326,7 +326,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
static struct ip_tunnel *ip_tunnel_create(struct net *net, static struct ip_tunnel *ip_tunnel_create(struct net *net,
struct ip_tunnel_net *itn, struct ip_tunnel_net *itn,
struct ip_tunnel_parm *parms) struct ip_tunnel_parm_kern *parms)
{ {
struct ip_tunnel *nt; struct ip_tunnel *nt;
struct net_device *dev; struct net_device *dev;
...@@ -871,7 +871,7 @@ EXPORT_SYMBOL_GPL(ip_tunnel_xmit); ...@@ -871,7 +871,7 @@ EXPORT_SYMBOL_GPL(ip_tunnel_xmit);
static void ip_tunnel_update(struct ip_tunnel_net *itn, static void ip_tunnel_update(struct ip_tunnel_net *itn,
struct ip_tunnel *t, struct ip_tunnel *t,
struct net_device *dev, struct net_device *dev,
struct ip_tunnel_parm *p, struct ip_tunnel_parm_kern *p,
bool set_mtu, bool set_mtu,
__u32 fwmark) __u32 fwmark)
{ {
...@@ -903,7 +903,8 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn, ...@@ -903,7 +903,8 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn,
netdev_state_change(dev); netdev_state_change(dev);
} }
int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p,
int cmd)
{ {
int err = 0; int err = 0;
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
...@@ -1005,16 +1006,52 @@ int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) ...@@ -1005,16 +1006,52 @@ int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
} }
EXPORT_SYMBOL_GPL(ip_tunnel_ctl); EXPORT_SYMBOL_GPL(ip_tunnel_ctl);
bool ip_tunnel_parm_from_user(struct ip_tunnel_parm_kern *kp,
const void __user *data)
{
struct ip_tunnel_parm p;
if (copy_from_user(&p, data, sizeof(p)))
return false;
strscpy(kp->name, p.name);
kp->link = p.link;
kp->i_flags = p.i_flags;
kp->o_flags = p.o_flags;
kp->i_key = p.i_key;
kp->o_key = p.o_key;
memcpy(&kp->iph, &p.iph, min(sizeof(kp->iph), sizeof(p.iph)));
return true;
}
EXPORT_SYMBOL_GPL(ip_tunnel_parm_from_user);
bool ip_tunnel_parm_to_user(void __user *data, struct ip_tunnel_parm_kern *kp)
{
struct ip_tunnel_parm p;
strscpy(p.name, kp->name);
p.link = kp->link;
p.i_flags = kp->i_flags;
p.o_flags = kp->o_flags;
p.i_key = kp->i_key;
p.o_key = kp->o_key;
memcpy(&p.iph, &kp->iph, min(sizeof(p.iph), sizeof(kp->iph)));
return !copy_to_user(data, &p, sizeof(p));
}
EXPORT_SYMBOL_GPL(ip_tunnel_parm_to_user);
int ip_tunnel_siocdevprivate(struct net_device *dev, struct ifreq *ifr, int ip_tunnel_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
void __user *data, int cmd) void __user *data, int cmd)
{ {
struct ip_tunnel_parm p; struct ip_tunnel_parm_kern p;
int err; int err;
if (copy_from_user(&p, data, sizeof(p))) if (!ip_tunnel_parm_from_user(&p, data))
return -EFAULT; return -EFAULT;
err = dev->netdev_ops->ndo_tunnel_ctl(dev, &p, cmd); err = dev->netdev_ops->ndo_tunnel_ctl(dev, &p, cmd);
if (!err && copy_to_user(data, &p, sizeof(p))) if (!err && !ip_tunnel_parm_to_user(data, &p))
return -EFAULT; return -EFAULT;
return err; return err;
} }
...@@ -1093,7 +1130,7 @@ int ip_tunnel_init_net(struct net *net, unsigned int ip_tnl_net_id, ...@@ -1093,7 +1130,7 @@ int ip_tunnel_init_net(struct net *net, unsigned int ip_tnl_net_id,
struct rtnl_link_ops *ops, char *devname) struct rtnl_link_ops *ops, char *devname)
{ {
struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id); struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
struct ip_tunnel_parm parms; struct ip_tunnel_parm_kern parms;
unsigned int i; unsigned int i;
itn->rtnl_link_ops = ops; itn->rtnl_link_ops = ops;
...@@ -1171,7 +1208,7 @@ void ip_tunnel_delete_nets(struct list_head *net_list, unsigned int id, ...@@ -1171,7 +1208,7 @@ void ip_tunnel_delete_nets(struct list_head *net_list, unsigned int id,
EXPORT_SYMBOL_GPL(ip_tunnel_delete_nets); EXPORT_SYMBOL_GPL(ip_tunnel_delete_nets);
int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
struct ip_tunnel_parm *p, __u32 fwmark) struct ip_tunnel_parm_kern *p, __u32 fwmark)
{ {
struct ip_tunnel *nt; struct ip_tunnel *nt;
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
...@@ -1225,7 +1262,7 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], ...@@ -1225,7 +1262,7 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
EXPORT_SYMBOL_GPL(ip_tunnel_newlink); EXPORT_SYMBOL_GPL(ip_tunnel_newlink);
int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[], int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[],
struct ip_tunnel_parm *p, __u32 fwmark) struct ip_tunnel_parm_kern *p, __u32 fwmark)
{ {
struct ip_tunnel *t; struct ip_tunnel *t;
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
......
...@@ -1116,7 +1116,7 @@ bool ip_tunnel_netlink_encap_parms(struct nlattr *data[], ...@@ -1116,7 +1116,7 @@ bool ip_tunnel_netlink_encap_parms(struct nlattr *data[],
EXPORT_SYMBOL_GPL(ip_tunnel_netlink_encap_parms); EXPORT_SYMBOL_GPL(ip_tunnel_netlink_encap_parms);
void ip_tunnel_netlink_parms(struct nlattr *data[], void ip_tunnel_netlink_parms(struct nlattr *data[],
struct ip_tunnel_parm *parms) struct ip_tunnel_parm_kern *parms)
{ {
if (data[IFLA_IPTUN_LINK]) if (data[IFLA_IPTUN_LINK])
parms->link = nla_get_u32(data[IFLA_IPTUN_LINK]); parms->link = nla_get_u32(data[IFLA_IPTUN_LINK]);
......
...@@ -167,7 +167,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev, ...@@ -167,7 +167,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
struct flowi *fl) struct flowi *fl)
{ {
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
struct ip_tunnel_parm *parms = &tunnel->parms; struct ip_tunnel_parm_kern *parms = &tunnel->parms;
struct dst_entry *dst = skb_dst(skb); struct dst_entry *dst = skb_dst(skb);
struct net_device *tdev; /* Device to other host */ struct net_device *tdev; /* Device to other host */
int pkt_len = skb->len; int pkt_len = skb->len;
...@@ -373,7 +373,7 @@ static int vti4_err(struct sk_buff *skb, u32 info) ...@@ -373,7 +373,7 @@ static int vti4_err(struct sk_buff *skb, u32 info)
} }
static int static int
vti_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) vti_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p, int cmd)
{ {
int err = 0; int err = 0;
...@@ -531,7 +531,7 @@ static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], ...@@ -531,7 +531,7 @@ static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
} }
static void vti_netlink_parms(struct nlattr *data[], static void vti_netlink_parms(struct nlattr *data[],
struct ip_tunnel_parm *parms, struct ip_tunnel_parm_kern *parms,
__u32 *fwmark) __u32 *fwmark)
{ {
memset(parms, 0, sizeof(*parms)); memset(parms, 0, sizeof(*parms));
...@@ -566,7 +566,7 @@ static int vti_newlink(struct net *src_net, struct net_device *dev, ...@@ -566,7 +566,7 @@ static int vti_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[], struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel_parm parms; struct ip_tunnel_parm_kern parms;
__u32 fwmark = 0; __u32 fwmark = 0;
vti_netlink_parms(data, &parms, &fwmark); vti_netlink_parms(data, &parms, &fwmark);
...@@ -578,8 +578,8 @@ static int vti_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -578,8 +578,8 @@ static int vti_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm_kern p;
__u32 fwmark = t->fwmark; __u32 fwmark = t->fwmark;
struct ip_tunnel_parm p;
vti_netlink_parms(data, &p, &fwmark); vti_netlink_parms(data, &p, &fwmark);
return ip_tunnel_changelink(dev, tb, &p, fwmark); return ip_tunnel_changelink(dev, tb, &p, fwmark);
...@@ -606,7 +606,7 @@ static size_t vti_get_size(const struct net_device *dev) ...@@ -606,7 +606,7 @@ static size_t vti_get_size(const struct net_device *dev)
static int vti_fill_info(struct sk_buff *skb, const struct net_device *dev) static int vti_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm *p = &t->parms; struct ip_tunnel_parm_kern *p = &t->parms;
if (nla_put_u32(skb, IFLA_VTI_LINK, p->link) || if (nla_put_u32(skb, IFLA_VTI_LINK, p->link) ||
nla_put_be32(skb, IFLA_VTI_IKEY, p->i_key) || nla_put_be32(skb, IFLA_VTI_IKEY, p->i_key) ||
......
...@@ -330,7 +330,7 @@ static bool ipip_tunnel_ioctl_verify_protocol(u8 ipproto) ...@@ -330,7 +330,7 @@ static bool ipip_tunnel_ioctl_verify_protocol(u8 ipproto)
} }
static int static int
ipip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) ipip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p, int cmd)
{ {
if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) { if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
if (p->iph.version != 4 || if (p->iph.version != 4 ||
...@@ -405,8 +405,8 @@ static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], ...@@ -405,8 +405,8 @@ static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
} }
static void ipip_netlink_parms(struct nlattr *data[], static void ipip_netlink_parms(struct nlattr *data[],
struct ip_tunnel_parm *parms, bool *collect_md, struct ip_tunnel_parm_kern *parms,
__u32 *fwmark) bool *collect_md, __u32 *fwmark)
{ {
memset(parms, 0, sizeof(*parms)); memset(parms, 0, sizeof(*parms));
...@@ -432,8 +432,8 @@ static int ipip_newlink(struct net *src_net, struct net_device *dev, ...@@ -432,8 +432,8 @@ static int ipip_newlink(struct net *src_net, struct net_device *dev,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm p;
struct ip_tunnel_encap ipencap; struct ip_tunnel_encap ipencap;
struct ip_tunnel_parm_kern p;
__u32 fwmark = 0; __u32 fwmark = 0;
if (ip_tunnel_netlink_encap_parms(data, &ipencap)) { if (ip_tunnel_netlink_encap_parms(data, &ipencap)) {
...@@ -452,8 +452,8 @@ static int ipip_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -452,8 +452,8 @@ static int ipip_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm p;
struct ip_tunnel_encap ipencap; struct ip_tunnel_encap ipencap;
struct ip_tunnel_parm_kern p;
bool collect_md; bool collect_md;
__u32 fwmark = t->fwmark; __u32 fwmark = t->fwmark;
...@@ -510,7 +510,7 @@ static size_t ipip_get_size(const struct net_device *dev) ...@@ -510,7 +510,7 @@ static size_t ipip_get_size(const struct net_device *dev)
static int ipip_fill_info(struct sk_buff *skb, const struct net_device *dev) static int ipip_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
struct ip_tunnel_parm *parm = &tunnel->parms; struct ip_tunnel_parm_kern *parm = &tunnel->parms;
if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) || nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
......
...@@ -441,7 +441,7 @@ static bool ipmr_init_vif_indev(const struct net_device *dev) ...@@ -441,7 +441,7 @@ static bool ipmr_init_vif_indev(const struct net_device *dev)
static struct net_device *ipmr_new_tunnel(struct net *net, struct vifctl *v) static struct net_device *ipmr_new_tunnel(struct net *net, struct vifctl *v)
{ {
struct net_device *tunnel_dev, *new_dev; struct net_device *tunnel_dev, *new_dev;
struct ip_tunnel_parm p = { }; struct ip_tunnel_parm_kern p = { };
int err; int err;
tunnel_dev = __dev_get_by_name(net, "tunl0"); tunnel_dev = __dev_get_by_name(net, "tunl0");
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/hash.h> #include <linux/hash.h>
#include <net/ip_tunnels.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/snmp.h> #include <net/snmp.h>
...@@ -2917,7 +2918,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) ...@@ -2917,7 +2918,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
static int addrconf_set_sit_dstaddr(struct net *net, struct net_device *dev, static int addrconf_set_sit_dstaddr(struct net *net, struct net_device *dev,
struct in6_ifreq *ireq) struct in6_ifreq *ireq)
{ {
struct ip_tunnel_parm p = { }; struct ip_tunnel_parm_kern p = { };
int err; int err;
if (!(ipv6_addr_type(&ireq->ifr6_addr) & IPV6_ADDR_COMPATv4)) if (!(ipv6_addr_type(&ireq->ifr6_addr) & IPV6_ADDR_COMPATv4))
......
...@@ -132,8 +132,8 @@ static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net, ...@@ -132,8 +132,8 @@ static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net,
return NULL; return NULL;
} }
static struct ip_tunnel __rcu **__ipip6_bucket(struct sit_net *sitn, static struct ip_tunnel __rcu **
struct ip_tunnel_parm *parms) __ipip6_bucket(struct sit_net *sitn, struct ip_tunnel_parm_kern *parms)
{ {
__be32 remote = parms->iph.daddr; __be32 remote = parms->iph.daddr;
__be32 local = parms->iph.saddr; __be32 local = parms->iph.saddr;
...@@ -226,7 +226,8 @@ static int ipip6_tunnel_create(struct net_device *dev) ...@@ -226,7 +226,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
} }
static struct ip_tunnel *ipip6_tunnel_locate(struct net *net, static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
struct ip_tunnel_parm *parms, int create) struct ip_tunnel_parm_kern *parms,
int create)
{ {
__be32 remote = parms->iph.daddr; __be32 remote = parms->iph.daddr;
__be32 local = parms->iph.saddr; __be32 local = parms->iph.saddr;
...@@ -1135,7 +1136,8 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev) ...@@ -1135,7 +1136,8 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
dev->needed_headroom = t_hlen + hlen; dev->needed_headroom = t_hlen + hlen;
} }
static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p, static void ipip6_tunnel_update(struct ip_tunnel *t,
struct ip_tunnel_parm_kern *p,
__u32 fwmark) __u32 fwmark)
{ {
struct net *net = t->net; struct net *net = t->net;
...@@ -1196,11 +1198,11 @@ static int ...@@ -1196,11 +1198,11 @@ static int
ipip6_tunnel_get6rd(struct net_device *dev, struct ip_tunnel_parm __user *data) ipip6_tunnel_get6rd(struct net_device *dev, struct ip_tunnel_parm __user *data)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm_kern p;
struct ip_tunnel_6rd ip6rd; struct ip_tunnel_6rd ip6rd;
struct ip_tunnel_parm p;
if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) { if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) {
if (copy_from_user(&p, data, sizeof(p))) if (!ip_tunnel_parm_from_user(&p, data))
return -EFAULT; return -EFAULT;
t = ipip6_tunnel_locate(t->net, &p, 0); t = ipip6_tunnel_locate(t->net, &p, 0);
} }
...@@ -1251,7 +1253,7 @@ static bool ipip6_valid_ip_proto(u8 ipproto) ...@@ -1251,7 +1253,7 @@ static bool ipip6_valid_ip_proto(u8 ipproto)
} }
static int static int
__ipip6_tunnel_ioctl_validate(struct net *net, struct ip_tunnel_parm *p) __ipip6_tunnel_ioctl_validate(struct net *net, struct ip_tunnel_parm_kern *p)
{ {
if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM; return -EPERM;
...@@ -1268,7 +1270,7 @@ __ipip6_tunnel_ioctl_validate(struct net *net, struct ip_tunnel_parm *p) ...@@ -1268,7 +1270,7 @@ __ipip6_tunnel_ioctl_validate(struct net *net, struct ip_tunnel_parm *p)
} }
static int static int
ipip6_tunnel_get(struct net_device *dev, struct ip_tunnel_parm *p) ipip6_tunnel_get(struct net_device *dev, struct ip_tunnel_parm_kern *p)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
...@@ -1281,7 +1283,7 @@ ipip6_tunnel_get(struct net_device *dev, struct ip_tunnel_parm *p) ...@@ -1281,7 +1283,7 @@ ipip6_tunnel_get(struct net_device *dev, struct ip_tunnel_parm *p)
} }
static int static int
ipip6_tunnel_add(struct net_device *dev, struct ip_tunnel_parm *p) ipip6_tunnel_add(struct net_device *dev, struct ip_tunnel_parm_kern *p)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
int err; int err;
...@@ -1297,7 +1299,7 @@ ipip6_tunnel_add(struct net_device *dev, struct ip_tunnel_parm *p) ...@@ -1297,7 +1299,7 @@ ipip6_tunnel_add(struct net_device *dev, struct ip_tunnel_parm *p)
} }
static int static int
ipip6_tunnel_change(struct net_device *dev, struct ip_tunnel_parm *p) ipip6_tunnel_change(struct net_device *dev, struct ip_tunnel_parm_kern *p)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
int err; int err;
...@@ -1328,7 +1330,7 @@ ipip6_tunnel_change(struct net_device *dev, struct ip_tunnel_parm *p) ...@@ -1328,7 +1330,7 @@ ipip6_tunnel_change(struct net_device *dev, struct ip_tunnel_parm *p)
} }
static int static int
ipip6_tunnel_del(struct net_device *dev, struct ip_tunnel_parm *p) ipip6_tunnel_del(struct net_device *dev, struct ip_tunnel_parm_kern *p)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
...@@ -1348,7 +1350,8 @@ ipip6_tunnel_del(struct net_device *dev, struct ip_tunnel_parm *p) ...@@ -1348,7 +1350,8 @@ ipip6_tunnel_del(struct net_device *dev, struct ip_tunnel_parm *p)
} }
static int static int
ipip6_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) ipip6_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p,
int cmd)
{ {
switch (cmd) { switch (cmd) {
case SIOCGETTUNNEL: case SIOCGETTUNNEL:
...@@ -1490,7 +1493,7 @@ static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[], ...@@ -1490,7 +1493,7 @@ static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[],
} }
static void ipip6_netlink_parms(struct nlattr *data[], static void ipip6_netlink_parms(struct nlattr *data[],
struct ip_tunnel_parm *parms, struct ip_tunnel_parm_kern *parms,
__u32 *fwmark) __u32 *fwmark)
{ {
memset(parms, 0, sizeof(*parms)); memset(parms, 0, sizeof(*parms));
...@@ -1599,8 +1602,8 @@ static int ipip6_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -1599,8 +1602,8 @@ static int ipip6_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm p;
struct ip_tunnel_encap ipencap; struct ip_tunnel_encap ipencap;
struct ip_tunnel_parm_kern p;
struct net *net = t->net; struct net *net = t->net;
struct sit_net *sitn = net_generic(net, sit_net_id); struct sit_net *sitn = net_generic(net, sit_net_id);
#ifdef CONFIG_IPV6_SIT_6RD #ifdef CONFIG_IPV6_SIT_6RD
...@@ -1687,7 +1690,7 @@ static size_t ipip6_get_size(const struct net_device *dev) ...@@ -1687,7 +1690,7 @@ static size_t ipip6_get_size(const struct net_device *dev)
static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev) static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
struct ip_tunnel_parm *parm = &tunnel->parms; struct ip_tunnel_parm_kern *parm = &tunnel->parms;
if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) || nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
......
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