diff options
author | Petr Machata <petrm@mellanox.com> | 2018-05-17 10:36:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-17 16:50:06 -0400 |
commit | a483373ead61e6079bc8ebe27e2dfdb2e3c1559f (patch) | |
tree | 5b44a0e3b07bf61d6b4868fe0d9129bde4dd4fa9 | |
parent | 5691484df961aff897d824bcc26cd1a2aa036b5b (diff) |
net: ip6_gre: Split up ip6gre_tnl_link_config()
The function ip6gre_tnl_link_config() is used for setting up
configuration of both ip6gretap and ip6erspan tunnels. Split the
function into the common part and the route-lookup part. The latter then
takes the calculated header length as an argument. This split will allow
the patches down the line to sneak in a custom header length computation
for the ERSPAN tunnel.
Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/ip6_gre.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 14c069b59a90..5d0a3b1ee0e9 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -1025,12 +1025,11 @@ tx_err: | |||
1025 | return NETDEV_TX_OK; | 1025 | return NETDEV_TX_OK; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) | 1028 | static void ip6gre_tnl_link_config_common(struct ip6_tnl *t) |
1029 | { | 1029 | { |
1030 | struct net_device *dev = t->dev; | 1030 | struct net_device *dev = t->dev; |
1031 | struct __ip6_tnl_parm *p = &t->parms; | 1031 | struct __ip6_tnl_parm *p = &t->parms; |
1032 | struct flowi6 *fl6 = &t->fl.u.ip6; | 1032 | struct flowi6 *fl6 = &t->fl.u.ip6; |
1033 | int t_hlen; | ||
1034 | 1033 | ||
1035 | if (dev->type != ARPHRD_ETHER) { | 1034 | if (dev->type != ARPHRD_ETHER) { |
1036 | memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); | 1035 | memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); |
@@ -1057,12 +1056,13 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) | |||
1057 | dev->flags |= IFF_POINTOPOINT; | 1056 | dev->flags |= IFF_POINTOPOINT; |
1058 | else | 1057 | else |
1059 | dev->flags &= ~IFF_POINTOPOINT; | 1058 | dev->flags &= ~IFF_POINTOPOINT; |
1059 | } | ||
1060 | 1060 | ||
1061 | t->tun_hlen = gre_calc_hlen(t->parms.o_flags); | 1061 | static void ip6gre_tnl_link_config_route(struct ip6_tnl *t, int set_mtu, |
1062 | 1062 | int t_hlen) | |
1063 | t->hlen = t->encap_hlen + t->tun_hlen; | 1063 | { |
1064 | 1064 | const struct __ip6_tnl_parm *p = &t->parms; | |
1065 | t_hlen = t->hlen + sizeof(struct ipv6hdr); | 1065 | struct net_device *dev = t->dev; |
1066 | 1066 | ||
1067 | if (p->flags & IP6_TNL_F_CAP_XMIT) { | 1067 | if (p->flags & IP6_TNL_F_CAP_XMIT) { |
1068 | int strict = (ipv6_addr_type(&p->raddr) & | 1068 | int strict = (ipv6_addr_type(&p->raddr) & |
@@ -1094,6 +1094,24 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) | |||
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | static int ip6gre_calc_hlen(struct ip6_tnl *tunnel) | ||
1098 | { | ||
1099 | int t_hlen; | ||
1100 | |||
1101 | tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); | ||
1102 | tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; | ||
1103 | |||
1104 | t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); | ||
1105 | tunnel->dev->hard_header_len = LL_MAX_HEADER + t_hlen; | ||
1106 | return t_hlen; | ||
1107 | } | ||
1108 | |||
1109 | static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) | ||
1110 | { | ||
1111 | ip6gre_tnl_link_config_common(t); | ||
1112 | ip6gre_tnl_link_config_route(t, set_mtu, ip6gre_calc_hlen(t)); | ||
1113 | } | ||
1114 | |||
1097 | static int ip6gre_tnl_change(struct ip6_tnl *t, | 1115 | static int ip6gre_tnl_change(struct ip6_tnl *t, |
1098 | const struct __ip6_tnl_parm *p, int set_mtu) | 1116 | const struct __ip6_tnl_parm *p, int set_mtu) |
1099 | { | 1117 | { |
@@ -1387,11 +1405,7 @@ static int ip6gre_tunnel_init_common(struct net_device *dev) | |||
1387 | return ret; | 1405 | return ret; |
1388 | } | 1406 | } |
1389 | 1407 | ||
1390 | tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); | 1408 | t_hlen = ip6gre_calc_hlen(tunnel); |
1391 | tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; | ||
1392 | t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); | ||
1393 | |||
1394 | dev->hard_header_len = LL_MAX_HEADER + t_hlen; | ||
1395 | dev->mtu = ETH_DATA_LEN - t_hlen; | 1409 | dev->mtu = ETH_DATA_LEN - t_hlen; |
1396 | if (dev->type == ARPHRD_ETHER) | 1410 | if (dev->type == ARPHRD_ETHER) |
1397 | dev->mtu -= ETH_HLEN; | 1411 | dev->mtu -= ETH_HLEN; |