Skip to content

Commit f78c75d

Browse files
pmachatakuba-moo
authored andcommitted
net: ipv6: Add a flags argument to ip6tunnel_xmit(), udp_tunnel6_xmit_skb()
ip6tunnel_xmit() erases the contents of the SKB control block. In order to be able to set particular IP6CB flags on the SKB, add a corresponding parameter, and propagate it to udp_tunnel6_xmit_skb() as well. In one of the following patches, VXLAN driver will use this facility to mark packets as subject to IPv6 multicast routing. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Link: https://patch.msgid.link/acb4f9f3e40c3a931236c3af08a720b017fbfbfb.1750113335.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6a7d88c commit f78c75d

File tree

12 files changed

+19
-13
lines changed

12 files changed

+19
-13
lines changed

drivers/net/bareudp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
431431
&saddr, &daddr, prio, ttl,
432432
info->key.label, sport, bareudp->port,
433433
!test_bit(IP_TUNNEL_CSUM_BIT,
434-
info->key.tun_flags));
434+
info->key.tun_flags),
435+
0);
435436
return 0;
436437

437438
free_dst:

drivers/net/geneve.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,8 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
10141014
&saddr, &key->u.ipv6.dst, prio, ttl,
10151015
info->key.label, sport, geneve->cfg.info.key.tp_dst,
10161016
!test_bit(IP_TUNNEL_CSUM_BIT,
1017-
info->key.tun_flags));
1017+
info->key.tun_flags),
1018+
0);
10181019
return 0;
10191020
}
10201021
#endif

drivers/net/gtp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)
13161316
ip6_dst_hoplimit(&pktinfo.rt->dst),
13171317
0,
13181318
pktinfo.gtph_port, pktinfo.gtph_port,
1319-
false);
1319+
false, 0);
13201320
#else
13211321
goto tx_err;
13221322
#endif

drivers/net/ovpn/udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind,
274274
skb->ignore_df = 1;
275275
udp_tunnel6_xmit_skb(dst, sk, skb, skb->dev, &fl.saddr, &fl.daddr, 0,
276276
ip6_dst_hoplimit(dst), 0, fl.fl6_sport,
277-
fl.fl6_dport, udp_get_no_check6_tx(sk));
277+
fl.fl6_dport, udp_get_no_check6_tx(sk), 0);
278278
ret = 0;
279279
err:
280280
local_bh_enable();

drivers/net/vxlan/vxlan_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,8 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
25862586

25872587
udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev,
25882588
&saddr, &pkey->u.ipv6.dst, tos, ttl,
2589-
pkey->label, src_port, dst_port, !udp_sum);
2589+
pkey->label, src_port, dst_port, !udp_sum,
2590+
0);
25902591
#endif
25912592
}
25922593
vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX, pkt_len);

drivers/net/wireguard/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int send6(struct wg_device *wg, struct sk_buff *skb,
151151
skb->ignore_df = 1;
152152
udp_tunnel6_xmit_skb(dst, sock, skb, skb->dev, &fl.saddr, &fl.daddr, ds,
153153
ip6_dst_hoplimit(dst), 0, fl.fl6_sport,
154-
fl.fl6_dport, false);
154+
fl.fl6_dport, false, 0);
155155
goto out;
156156

157157
err:

include/net/ip6_tunnel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@ int ip6_tnl_get_iflink(const struct net_device *dev);
152152
int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu);
153153

154154
static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
155-
struct net_device *dev)
155+
struct net_device *dev, u16 ip6cb_flags)
156156
{
157157
int pkt_len, err;
158158

159159
memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
160+
IP6CB(skb)->flags = ip6cb_flags;
160161
pkt_len = skb->len - skb_inner_network_offset(skb);
161162
err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
162163

include/net/udp_tunnel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
158158
const struct in6_addr *saddr,
159159
const struct in6_addr *daddr,
160160
__u8 prio, __u8 ttl, __be32 label,
161-
__be16 src_port, __be16 dst_port, bool nocheck);
161+
__be16 src_port, __be16 dst_port, bool nocheck,
162+
u16 ip6cb_flags);
162163

163164
void udp_tunnel_sock_release(struct socket *sock);
164165

net/ipv6/ip6_tunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
12781278
ipv6h->nexthdr = proto;
12791279
ipv6h->saddr = fl6->saddr;
12801280
ipv6h->daddr = fl6->daddr;
1281-
ip6tunnel_xmit(NULL, skb, dev);
1281+
ip6tunnel_xmit(NULL, skb, dev, 0);
12821282
return 0;
12831283
tx_err_link_failure:
12841284
DEV_STATS_INC(dev, tx_carrier_errors);

net/ipv6/ip6_udp_tunnel.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
8080
const struct in6_addr *saddr,
8181
const struct in6_addr *daddr,
8282
__u8 prio, __u8 ttl, __be32 label,
83-
__be16 src_port, __be16 dst_port, bool nocheck)
83+
__be16 src_port, __be16 dst_port, bool nocheck,
84+
u16 ip6cb_flags)
8485
{
8586
struct udphdr *uh;
8687
struct ipv6hdr *ip6h;
@@ -108,7 +109,7 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
108109
ip6h->daddr = *daddr;
109110
ip6h->saddr = *saddr;
110111

111-
ip6tunnel_xmit(sk, skb, dev);
112+
ip6tunnel_xmit(sk, skb, dev, ip6cb_flags);
112113
}
113114
EXPORT_SYMBOL_GPL(udp_tunnel6_xmit_skb);
114115

net/sctp/ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *t)
263263

264264
udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr, &fl6->daddr,
265265
tclass, ip6_dst_hoplimit(dst), label,
266-
sctp_sk(sk)->udp_port, t->encap_port, false);
266+
sctp_sk(sk)->udp_port, t->encap_port, false, 0);
267267
return 0;
268268
}
269269

net/tipc/udp_media.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
219219
ttl = ip6_dst_hoplimit(ndst);
220220
udp_tunnel6_xmit_skb(ndst, ub->ubsock->sk, skb, NULL,
221221
&src->ipv6, &dst->ipv6, 0, ttl, 0,
222-
src->port, dst->port, false);
222+
src->port, dst->port, false, 0);
223223
#endif
224224
}
225225
local_bh_enable();

0 commit comments

Comments
 (0)