Skip to content

Commit

Permalink
udp: Do not require sock in udp_tunnel_xmit_skb
Browse files Browse the repository at this point in the history
The UDP tunnel transmit functions udp_tunnel_xmit_skb and
udp_tunnel6_xmit_skb include a socket argument. The socket being
passed to the functions (from VXLAN) is a UDP created for receive
side. The only thing that the socket is used for in the transmit
functions is to get the setting for checksum (enabled or zero).
This patch removes the argument and and adds a nocheck argument
for checksum setting. This eliminates the unnecessary dependency
on a UDP socket for UDP tunnel transmit.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Herbert authored and David S. Miller committed Jan 25, 2015
1 parent 2b995f6 commit d998f8e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
10 changes: 6 additions & 4 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,9 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,

skb_set_inner_protocol(skb, htons(ETH_P_TEB));

udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio,
ttl, src_port, dst_port);
udp_tunnel6_xmit_skb(dst, skb, dev, saddr, daddr, prio,
ttl, src_port, dst_port,
udp_get_no_check6_tx(vs->sock->sk));
return 0;
err:
dst_release(dst);
Expand Down Expand Up @@ -1848,8 +1849,9 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,

skb_set_inner_protocol(skb, htons(ETH_P_TEB));

return udp_tunnel_xmit_skb(vs->sock, rt, skb, src, dst, tos,
ttl, df, src_port, dst_port, xnet);
return udp_tunnel_xmit_skb(rt, skb, src, dst, tos,
ttl, df, src_port, dst_port, xnet,
vs->sock->sk->sk_no_check_tx);
}
EXPORT_SYMBOL_GPL(vxlan_xmit_skb);

Expand Down
16 changes: 8 additions & 8 deletions include/net/udp_tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
struct udp_tunnel_sock_cfg *sock_cfg);

/* Transmit the skb using UDP encapsulation. */
int udp_tunnel_xmit_skb(struct socket *sock, struct rtable *rt,
struct sk_buff *skb, __be32 src, __be32 dst,
__u8 tos, __u8 ttl, __be16 df, __be16 src_port,
__be16 dst_port, bool xnet);
int udp_tunnel_xmit_skb(struct rtable *rt, struct sk_buff *skb,
__be32 src, __be32 dst, __u8 tos, __u8 ttl,
__be16 df, __be16 src_port, __be16 dst_port,
bool xnet, bool nocheck);

#if IS_ENABLED(CONFIG_IPV6)
int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *dst,
struct sk_buff *skb, struct net_device *dev,
struct in6_addr *saddr, struct in6_addr *daddr,
int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sk_buff *skb,
struct net_device *dev, struct in6_addr *saddr,
struct in6_addr *daddr,
__u8 prio, __u8 ttl, __be16 src_port,
__be16 dst_port);
__be16 dst_port, bool nocheck);
#endif

void udp_tunnel_sock_release(struct socket *sock);
Expand Down
5 changes: 3 additions & 2 deletions net/ipv4/geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,

skb_set_inner_protocol(skb, htons(ETH_P_TEB));

return udp_tunnel_xmit_skb(gs->sock, rt, skb, src, dst,
tos, ttl, df, src_port, dst_port, xnet);
return udp_tunnel_xmit_skb(rt, skb, src, dst,
tos, ttl, df, src_port, dst_port, xnet,
gs->sock->sk->sk_no_check_tx);
}
EXPORT_SYMBOL_GPL(geneve_xmit_skb);

Expand Down
12 changes: 6 additions & 6 deletions net/ipv4/udp_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
}
EXPORT_SYMBOL_GPL(setup_udp_tunnel_sock);

int udp_tunnel_xmit_skb(struct socket *sock, struct rtable *rt,
struct sk_buff *skb, __be32 src, __be32 dst,
__u8 tos, __u8 ttl, __be16 df, __be16 src_port,
__be16 dst_port, bool xnet)
int udp_tunnel_xmit_skb(struct rtable *rt, struct sk_buff *skb,
__be32 src, __be32 dst, __u8 tos, __u8 ttl,
__be16 df, __be16 src_port, __be16 dst_port,
bool xnet, bool nocheck)
{
struct udphdr *uh;

Expand All @@ -90,9 +90,9 @@ int udp_tunnel_xmit_skb(struct socket *sock, struct rtable *rt,
uh->source = src_port;
uh->len = htons(skb->len);

udp_set_csum(sock->sk->sk_no_check_tx, skb, src, dst, skb->len);
udp_set_csum(nocheck, skb, src, dst, skb->len);

return iptunnel_xmit(sock->sk, rt, skb, src, dst, IPPROTO_UDP,
return iptunnel_xmit(skb->sk, rt, skb, src, dst, IPPROTO_UDP,
tos, ttl, df, xnet);
}
EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb);
Expand Down
12 changes: 6 additions & 6 deletions net/ipv6/ip6_udp_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
}
EXPORT_SYMBOL_GPL(udp_sock_create6);

int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *dst,
struct sk_buff *skb, struct net_device *dev,
struct in6_addr *saddr, struct in6_addr *daddr,
__u8 prio, __u8 ttl, __be16 src_port, __be16 dst_port)
int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sk_buff *skb,
struct net_device *dev, struct in6_addr *saddr,
struct in6_addr *daddr,
__u8 prio, __u8 ttl, __be16 src_port,
__be16 dst_port, bool nocheck)
{
struct udphdr *uh;
struct ipv6hdr *ip6h;
struct sock *sk = sock->sk;

__skb_push(skb, sizeof(*uh));
skb_reset_transport_header(skb);
Expand All @@ -85,7 +85,7 @@ int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *dst,
| IPSKB_REROUTED);
skb_dst_set(skb, dst);

udp6_set_csum(udp_get_no_check6_tx(sk), skb, saddr, daddr, skb->len);
udp6_set_csum(nocheck, skb, saddr, daddr, skb->len);

__skb_push(skb, sizeof(*ip6h));
skb_reset_network_header(skb);
Expand Down

0 comments on commit d998f8e

Please sign in to comment.