Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 300731
b: refs/heads/master
c: 447167b
h: refs/heads/master
i:
  300729: dfaa97a
  300727: 2d9afca
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Apr 13, 2012
1 parent ec7ebb3 commit bb313df
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 77577bf93275b485cecb4f358a085949c32e9dcd
refs/heads/master: 447167bf565a474ff0cfb0f41d54936937479e97
1 change: 1 addition & 0 deletions trunk/include/net/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,5 @@ extern void udp_init(void);
extern int udp4_ufo_send_check(struct sk_buff *skb);
extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
netdev_features_t features);
extern void udp_encap_enable(void);
#endif /* _UDP_H */
12 changes: 11 additions & 1 deletion trunk/net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
#include <net/checksum.h>
#include <net/xfrm.h>
#include <trace/events/udp.h>
#include <linux/static_key.h>
#include "udp_impl.h"

struct udp_table udp_table __read_mostly;
Expand Down Expand Up @@ -1379,6 +1380,14 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)

}

static struct static_key udp_encap_needed __read_mostly;
void udp_encap_enable(void)
{
if (!static_key_enabled(&udp_encap_needed))
static_key_slow_inc(&udp_encap_needed);
}
EXPORT_SYMBOL(udp_encap_enable);

/* returns:
* -1: error
* 0: success
Expand All @@ -1400,7 +1409,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
goto drop;
nf_reset(skb);

if (up->encap_type) {
if (static_key_false(&udp_encap_needed) && up->encap_type) {
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);

/*
Expand Down Expand Up @@ -1760,6 +1769,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
/* FALLTHROUGH */
case UDP_ENCAP_L2TPINUDP:
up->encap_type = val;
udp_encap_enable();
break;
default:
err = -ENOPROTOOPT;
Expand Down
1 change: 1 addition & 0 deletions trunk/net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
/* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
udp_sk(sk)->encap_type = UDP_ENCAP_L2TPINUDP;
udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv;
udp_encap_enable();
}

sk->sk_user_data = tunnel;
Expand Down

0 comments on commit bb313df

Please sign in to comment.