mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-12 01:20:14 +00:00
net: ipv4: Add a flags argument to iptunnel_xmit(), udp_tunnel_xmit_skb()
iptunnel_xmit() erases the contents of the SKB control block. In order to be able to set particular IPCB flags on the SKB, add a corresponding parameter, and propagate it to udp_tunnel_xmit_skb() as well. In one of the following patches, VXLAN driver will use this facility to mark packets as subject to IP multicast routing. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Acked-by: Antonio Quartulli <antonio@openvpn.net> Link: https://patch.msgid.link/89c9daf9f2dc088b6b92ccebcc929f51742de91f.1750113335.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
ccde40812a
commit
e3411e326f
@ -1046,7 +1046,8 @@ static bool amt_send_membership_update(struct amt_dev *amt,
|
||||
amt->gw_port,
|
||||
amt->relay_port,
|
||||
false,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
amt_update_gw_status(amt, AMT_STATUS_SENT_UPDATE, true);
|
||||
return false;
|
||||
}
|
||||
@ -1103,7 +1104,8 @@ static void amt_send_multicast_data(struct amt_dev *amt,
|
||||
amt->relay_port,
|
||||
tunnel->source_port,
|
||||
false,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
}
|
||||
|
||||
static bool amt_send_membership_query(struct amt_dev *amt,
|
||||
@ -1161,7 +1163,8 @@ static bool amt_send_membership_query(struct amt_dev *amt,
|
||||
amt->relay_port,
|
||||
tunnel->source_port,
|
||||
false,
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
amt_update_relay_status(tunnel, AMT_STATUS_SENT_QUERY, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -362,8 +362,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
|
||||
udp_tunnel_xmit_skb(rt, sock->sk, skb, saddr, info->key.u.ipv4.dst,
|
||||
tos, ttl, df, sport, bareudp->port,
|
||||
!net_eq(bareudp->net, dev_net(bareudp->dev)),
|
||||
!test_bit(IP_TUNNEL_CSUM_BIT,
|
||||
info->key.tun_flags));
|
||||
!test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags),
|
||||
0);
|
||||
return 0;
|
||||
|
||||
free_dst:
|
||||
|
||||
@ -921,8 +921,8 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
|
||||
udp_tunnel_xmit_skb(rt, gs4->sock->sk, skb, saddr, info->key.u.ipv4.dst,
|
||||
tos, ttl, df, sport, geneve->cfg.info.key.tp_dst,
|
||||
!net_eq(geneve->net, dev_net(geneve->dev)),
|
||||
!test_bit(IP_TUNNEL_CSUM_BIT,
|
||||
info->key.tun_flags));
|
||||
!test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags),
|
||||
0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -446,7 +446,8 @@ static int gtp0_send_echo_resp_ip(struct gtp_dev *gtp, struct sk_buff *skb)
|
||||
htons(GTP0_PORT), htons(GTP0_PORT),
|
||||
!net_eq(sock_net(gtp->sk1u),
|
||||
dev_net(gtp->dev)),
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -704,7 +705,8 @@ static int gtp1u_send_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb)
|
||||
htons(GTP1U_PORT), htons(GTP1U_PORT),
|
||||
!net_eq(sock_net(gtp->sk1u),
|
||||
dev_net(gtp->dev)),
|
||||
false);
|
||||
false,
|
||||
0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1304,7 +1306,7 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
pktinfo.gtph_port, pktinfo.gtph_port,
|
||||
!net_eq(sock_net(pktinfo.pctx->sk),
|
||||
dev_net(dev)),
|
||||
false);
|
||||
false, 0);
|
||||
break;
|
||||
case AF_INET6:
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
@ -2405,7 +2407,7 @@ static int gtp_genl_send_echo_req(struct sk_buff *skb, struct genl_info *info)
|
||||
port, port,
|
||||
!net_eq(sock_net(sk),
|
||||
dev_net(gtp->dev)),
|
||||
false);
|
||||
false, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ static int ovpn_udp4_output(struct ovpn_peer *peer, struct ovpn_bind *bind,
|
||||
transmit:
|
||||
udp_tunnel_xmit_skb(rt, sk, skb, fl.saddr, fl.daddr, 0,
|
||||
ip4_dst_hoplimit(&rt->dst), 0, fl.fl4_sport,
|
||||
fl.fl4_dport, false, sk->sk_no_check_tx);
|
||||
fl.fl4_dport, false, sk->sk_no_check_tx, 0);
|
||||
ret = 0;
|
||||
err:
|
||||
local_bh_enable();
|
||||
|
||||
@ -2522,7 +2522,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
|
||||
|
||||
udp_tunnel_xmit_skb(rt, sock4->sock->sk, skb, saddr,
|
||||
pkey->u.ipv4.dst, tos, ttl, df,
|
||||
src_port, dst_port, xnet, !udp_sum);
|
||||
src_port, dst_port, xnet, !udp_sum, 0);
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
} else {
|
||||
struct vxlan_sock *sock6 = rcu_dereference(vxlan->vn6_sock);
|
||||
|
||||
@ -84,7 +84,7 @@ static int send4(struct wg_device *wg, struct sk_buff *skb,
|
||||
skb->ignore_df = 1;
|
||||
udp_tunnel_xmit_skb(rt, sock, skb, fl.saddr, fl.daddr, ds,
|
||||
ip4_dst_hoplimit(&rt->dst), 0, fl.fl4_sport,
|
||||
fl.fl4_dport, false, false);
|
||||
fl.fl4_dport, false, false, 0);
|
||||
goto out;
|
||||
|
||||
err:
|
||||
|
||||
@ -603,7 +603,7 @@ static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
|
||||
|
||||
void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
|
||||
__be32 src, __be32 dst, u8 proto,
|
||||
u8 tos, u8 ttl, __be16 df, bool xnet);
|
||||
u8 tos, u8 ttl, __be16 df, bool xnet, u16 ipcb_flags);
|
||||
struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,
|
||||
gfp_t flags);
|
||||
int skb_tunnel_check_pmtu(struct sk_buff *skb, struct dst_entry *encap_dst,
|
||||
|
||||
@ -150,7 +150,7 @@ static inline void udp_tunnel_drop_rx_info(struct net_device *dev)
|
||||
void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
|
||||
__be32 src, __be32 dst, __u8 tos, __u8 ttl,
|
||||
__be16 df, __be16 src_port, __be16 dst_port,
|
||||
bool xnet, bool nocheck);
|
||||
bool xnet, bool nocheck, u16 ipcb_flags);
|
||||
|
||||
int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
|
||||
struct sk_buff *skb,
|
||||
|
||||
@ -668,7 +668,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||
ip_tunnel_adj_headroom(dev, headroom);
|
||||
|
||||
iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, tos, ttl,
|
||||
df, !net_eq(tunnel->net, dev_net(dev)));
|
||||
df, !net_eq(tunnel->net, dev_net(dev)), 0);
|
||||
return;
|
||||
tx_error:
|
||||
DEV_STATS_INC(dev, tx_errors);
|
||||
@ -857,7 +857,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||
ip_tunnel_adj_headroom(dev, max_headroom);
|
||||
|
||||
iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
|
||||
df, !net_eq(tunnel->net, dev_net(dev)));
|
||||
df, !net_eq(tunnel->net, dev_net(dev)), 0);
|
||||
return;
|
||||
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
|
||||
@ -49,7 +49,8 @@ EXPORT_SYMBOL(ip6tun_encaps);
|
||||
|
||||
void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
|
||||
__be32 src, __be32 dst, __u8 proto,
|
||||
__u8 tos, __u8 ttl, __be16 df, bool xnet)
|
||||
__u8 tos, __u8 ttl, __be16 df, bool xnet,
|
||||
u16 ipcb_flags)
|
||||
{
|
||||
int pkt_len = skb->len - skb_inner_network_offset(skb);
|
||||
struct net *net = dev_net(rt->dst.dev);
|
||||
@ -62,6 +63,7 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
|
||||
skb_clear_hash_if_not_l4(skb);
|
||||
skb_dst_set(skb, &rt->dst);
|
||||
memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
|
||||
IPCB(skb)->flags = ipcb_flags;
|
||||
|
||||
/* Push down and install the IP header. */
|
||||
skb_push(skb, sizeof(struct iphdr));
|
||||
|
||||
@ -169,7 +169,7 @@ EXPORT_SYMBOL_GPL(udp_tunnel_notify_del_rx_port);
|
||||
void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
|
||||
__be32 src, __be32 dst, __u8 tos, __u8 ttl,
|
||||
__be16 df, __be16 src_port, __be16 dst_port,
|
||||
bool xnet, bool nocheck)
|
||||
bool xnet, bool nocheck, u16 ipcb_flags)
|
||||
{
|
||||
struct udphdr *uh;
|
||||
|
||||
@ -185,7 +185,8 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb
|
||||
|
||||
udp_set_csum(nocheck, skb, src, dst, skb->len);
|
||||
|
||||
iptunnel_xmit(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, xnet);
|
||||
iptunnel_xmit(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, xnet,
|
||||
ipcb_flags);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb);
|
||||
|
||||
|
||||
@ -1035,7 +1035,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
|
||||
skb_set_inner_ipproto(skb, IPPROTO_IPV6);
|
||||
|
||||
iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
|
||||
df, !net_eq(tunnel->net, dev_net(dev)));
|
||||
df, !net_eq(tunnel->net, dev_net(dev)), 0);
|
||||
return NETDEV_TX_OK;
|
||||
|
||||
tx_error_icmp:
|
||||
|
||||
@ -1103,7 +1103,8 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, struct sctp_transport *t)
|
||||
skb_set_inner_ipproto(skb, IPPROTO_SCTP);
|
||||
udp_tunnel_xmit_skb(dst_rtable(dst), sk, skb, fl4->saddr,
|
||||
fl4->daddr, dscp, ip4_dst_hoplimit(dst), df,
|
||||
sctp_sk(sk)->udp_port, t->encap_port, false, false);
|
||||
sctp_sk(sk)->udp_port, t->encap_port, false, false,
|
||||
0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -197,7 +197,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
|
||||
ttl = ip4_dst_hoplimit(&rt->dst);
|
||||
udp_tunnel_xmit_skb(rt, ub->ubsock->sk, skb, src->ipv4.s_addr,
|
||||
dst->ipv4.s_addr, 0, ttl, 0, src->port,
|
||||
dst->port, false, true);
|
||||
dst->port, false, true, 0);
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
} else {
|
||||
if (!ndst) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user