Skip to content

Commit 8eb30be

Browse files
tomratbertdavem330
authored andcommitted
ipv6: Create ip6_tnl_xmit
This patch renames ip6_tnl_xmit2 to ip6_tnl_xmit and exports it. Other users like GRE will be able to call this. The original ip6_tnl_xmit function is renamed to ip6_tnl_start_xmit (this is an ndo_start_xmit function). Signed-off-by: Tom Herbert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 308edfd commit 8eb30be

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

include/net/ip6_tunnel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
6969
bool log_ecn_error);
7070
int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
7171
const struct in6_addr *raddr);
72+
int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
73+
struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);
7274
__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
7375
__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
7476
const struct in6_addr *raddr);

net/ipv6/ip6_tunnel.c

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,14 @@ int ip6_tnl_xmit_ctl(struct ip6_tnl *t,
979979
EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);
980980

981981
/**
982-
* ip6_tnl_xmit2 - encapsulate packet and send
982+
* ip6_tnl_xmit - encapsulate packet and send
983983
* @skb: the outgoing socket buffer
984984
* @dev: the outgoing tunnel device
985985
* @dsfield: dscp code for outer header
986-
* @fl: flow of tunneled packet
986+
* @fl6: flow of tunneled packet
987987
* @encap_limit: encapsulation limit
988988
* @pmtu: Path MTU is stored if packet is too big
989+
* @proto: next header value
989990
*
990991
* Description:
991992
* Build new header and do some sanity checks on the packet before sending
@@ -997,12 +998,9 @@ EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);
997998
* %-EMSGSIZE message too big. return mtu in this case.
998999
**/
9991000

1000-
static int ip6_tnl_xmit2(struct sk_buff *skb,
1001-
struct net_device *dev,
1002-
__u8 dsfield,
1003-
struct flowi6 *fl6,
1004-
int encap_limit,
1005-
__u32 *pmtu)
1001+
int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
1002+
struct flowi6 *fl6, int encap_limit, __u32 *pmtu,
1003+
__u8 proto)
10061004
{
10071005
struct ip6_tnl *t = netdev_priv(dev);
10081006
struct net *net = t->net;
@@ -1013,7 +1011,6 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
10131011
struct net_device *tdev;
10141012
int mtu;
10151013
unsigned int max_headroom = sizeof(struct ipv6hdr);
1016-
u8 proto;
10171014
int err = -1;
10181015

10191016
/* NBMA tunnel */
@@ -1075,12 +1072,23 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
10751072
mtu = IPV6_MIN_MTU;
10761073
if (skb_dst(skb))
10771074
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
1078-
if (skb->len > mtu) {
1075+
if (skb->len > mtu && !skb_is_gso(skb)) {
10791076
*pmtu = mtu;
10801077
err = -EMSGSIZE;
10811078
goto tx_err_dst_release;
10821079
}
10831080

1081+
if (t->err_count > 0) {
1082+
if (time_before(jiffies,
1083+
t->err_time + IP6TUNNEL_ERR_TIMEO)) {
1084+
t->err_count--;
1085+
1086+
dst_link_failure(skb);
1087+
} else {
1088+
t->err_count = 0;
1089+
}
1090+
}
1091+
10841092
skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
10851093

10861094
/*
@@ -1108,7 +1116,6 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
11081116

11091117
skb->transport_header = skb->network_header;
11101118

1111-
proto = fl6->flowi6_proto;
11121119
if (encap_limit >= 0) {
11131120
init_tel_txopt(&opt, encap_limit);
11141121
ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
@@ -1119,6 +1126,11 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
11191126
skb->encapsulation = 1;
11201127
}
11211128

1129+
max_headroom = LL_RESERVED_SPACE(dst->dev) + sizeof(struct ipv6hdr)
1130+
+ dst->header_len;
1131+
if (max_headroom > dev->needed_headroom)
1132+
dev->needed_headroom = max_headroom;
1133+
11221134
skb_push(skb, sizeof(struct ipv6hdr));
11231135
skb_reset_network_header(skb);
11241136
ipv6h = ipv6_hdr(skb);
@@ -1137,6 +1149,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
11371149
dst_release(dst);
11381150
return err;
11391151
}
1152+
EXPORT_SYMBOL(ip6_tnl_xmit);
11401153

11411154
static inline int
11421155
ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -1160,7 +1173,6 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
11601173
encap_limit = t->parms.encap_limit;
11611174

11621175
memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
1163-
fl6.flowi6_proto = IPPROTO_IPIP;
11641176

11651177
dsfield = ipv4_get_dsfield(iph);
11661178

@@ -1170,7 +1182,8 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
11701182
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
11711183
fl6.flowi6_mark = skb->mark;
11721184

1173-
err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
1185+
err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
1186+
IPPROTO_IPIP);
11741187
if (err != 0) {
11751188
/* XXX: send ICMP error even if DF is not set. */
11761189
if (err == -EMSGSIZE)
@@ -1214,7 +1227,6 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
12141227
encap_limit = t->parms.encap_limit;
12151228

12161229
memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
1217-
fl6.flowi6_proto = IPPROTO_IPV6;
12181230

12191231
dsfield = ipv6_get_dsfield(ipv6h);
12201232
if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
@@ -1224,7 +1236,8 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
12241236
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
12251237
fl6.flowi6_mark = skb->mark;
12261238

1227-
err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
1239+
err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
1240+
IPPROTO_IPV6);
12281241
if (err != 0) {
12291242
if (err == -EMSGSIZE)
12301243
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
@@ -1235,7 +1248,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
12351248
}
12361249

12371250
static netdev_tx_t
1238-
ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
1251+
ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
12391252
{
12401253
struct ip6_tnl *t = netdev_priv(dev);
12411254
struct net_device_stats *stats = &t->dev->stats;
@@ -1556,7 +1569,7 @@ EXPORT_SYMBOL(ip6_tnl_get_iflink);
15561569
static const struct net_device_ops ip6_tnl_netdev_ops = {
15571570
.ndo_init = ip6_tnl_dev_init,
15581571
.ndo_uninit = ip6_tnl_dev_uninit,
1559-
.ndo_start_xmit = ip6_tnl_xmit,
1572+
.ndo_start_xmit = ip6_tnl_start_xmit,
15601573
.ndo_do_ioctl = ip6_tnl_ioctl,
15611574
.ndo_change_mtu = ip6_tnl_change_mtu,
15621575
.ndo_get_stats = ip6_get_stats,

0 commit comments

Comments
 (0)