diff options
Diffstat (limited to 'net/ipv4/udplite.c')
-rw-r--r-- | net/ipv4/udplite.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 001b881ca36f..72ce26b6c4d3 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
@@ -17,17 +17,6 @@ DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics) __read_mostly; | |||
17 | 17 | ||
18 | struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; | 18 | struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; |
19 | 19 | ||
20 | int udplite_get_port(struct sock *sk, unsigned short p, | ||
21 | int (*c)(const struct sock *, const struct sock *)) | ||
22 | { | ||
23 | return __udp_lib_get_port(sk, p, udplite_hash, c); | ||
24 | } | ||
25 | |||
26 | static int udplite_v4_get_port(struct sock *sk, unsigned short snum) | ||
27 | { | ||
28 | return udplite_get_port(sk, snum, ipv4_rcv_saddr_equal); | ||
29 | } | ||
30 | |||
31 | static int udplite_rcv(struct sk_buff *skb) | 20 | static int udplite_rcv(struct sk_buff *skb) |
32 | { | 21 | { |
33 | return __udp4_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE); | 22 | return __udp4_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE); |
@@ -42,10 +31,9 @@ static struct net_protocol udplite_protocol = { | |||
42 | .handler = udplite_rcv, | 31 | .handler = udplite_rcv, |
43 | .err_handler = udplite_err, | 32 | .err_handler = udplite_err, |
44 | .no_policy = 1, | 33 | .no_policy = 1, |
34 | .netns_ok = 1, | ||
45 | }; | 35 | }; |
46 | 36 | ||
47 | DEFINE_PROTO_INUSE(udplite) | ||
48 | |||
49 | struct proto udplite_prot = { | 37 | struct proto udplite_prot = { |
50 | .name = "UDP-Lite", | 38 | .name = "UDP-Lite", |
51 | .owner = THIS_MODULE, | 39 | .owner = THIS_MODULE, |
@@ -63,13 +51,13 @@ struct proto udplite_prot = { | |||
63 | .backlog_rcv = udp_queue_rcv_skb, | 51 | .backlog_rcv = udp_queue_rcv_skb, |
64 | .hash = udp_lib_hash, | 52 | .hash = udp_lib_hash, |
65 | .unhash = udp_lib_unhash, | 53 | .unhash = udp_lib_unhash, |
66 | .get_port = udplite_v4_get_port, | 54 | .get_port = udp_v4_get_port, |
67 | .obj_size = sizeof(struct udp_sock), | 55 | .obj_size = sizeof(struct udp_sock), |
56 | .h.udp_hash = udplite_hash, | ||
68 | #ifdef CONFIG_COMPAT | 57 | #ifdef CONFIG_COMPAT |
69 | .compat_setsockopt = compat_udp_setsockopt, | 58 | .compat_setsockopt = compat_udp_setsockopt, |
70 | .compat_getsockopt = compat_udp_getsockopt, | 59 | .compat_getsockopt = compat_udp_getsockopt, |
71 | #endif | 60 | #endif |
72 | REF_PROTO_INUSE(udplite) | ||
73 | }; | 61 | }; |
74 | 62 | ||
75 | static struct inet_protosw udplite4_protosw = { | 63 | static struct inet_protosw udplite4_protosw = { |
@@ -83,15 +71,42 @@ static struct inet_protosw udplite4_protosw = { | |||
83 | }; | 71 | }; |
84 | 72 | ||
85 | #ifdef CONFIG_PROC_FS | 73 | #ifdef CONFIG_PROC_FS |
86 | static struct file_operations udplite4_seq_fops; | ||
87 | static struct udp_seq_afinfo udplite4_seq_afinfo = { | 74 | static struct udp_seq_afinfo udplite4_seq_afinfo = { |
88 | .owner = THIS_MODULE, | ||
89 | .name = "udplite", | 75 | .name = "udplite", |
90 | .family = AF_INET, | 76 | .family = AF_INET, |
91 | .hashtable = udplite_hash, | 77 | .hashtable = udplite_hash, |
92 | .seq_show = udp4_seq_show, | 78 | .seq_fops = { |
93 | .seq_fops = &udplite4_seq_fops, | 79 | .owner = THIS_MODULE, |
80 | }, | ||
81 | .seq_ops = { | ||
82 | .show = udp4_seq_show, | ||
83 | }, | ||
84 | }; | ||
85 | |||
86 | static int udplite4_proc_init_net(struct net *net) | ||
87 | { | ||
88 | return udp_proc_register(net, &udplite4_seq_afinfo); | ||
89 | } | ||
90 | |||
91 | static void udplite4_proc_exit_net(struct net *net) | ||
92 | { | ||
93 | udp_proc_unregister(net, &udplite4_seq_afinfo); | ||
94 | } | ||
95 | |||
96 | static struct pernet_operations udplite4_net_ops = { | ||
97 | .init = udplite4_proc_init_net, | ||
98 | .exit = udplite4_proc_exit_net, | ||
94 | }; | 99 | }; |
100 | |||
101 | static __init int udplite4_proc_init(void) | ||
102 | { | ||
103 | return register_pernet_subsys(&udplite4_net_ops); | ||
104 | } | ||
105 | #else | ||
106 | static inline int udplite4_proc_init(void) | ||
107 | { | ||
108 | return 0; | ||
109 | } | ||
95 | #endif | 110 | #endif |
96 | 111 | ||
97 | void __init udplite4_register(void) | 112 | void __init udplite4_register(void) |
@@ -104,18 +119,15 @@ void __init udplite4_register(void) | |||
104 | 119 | ||
105 | inet_register_protosw(&udplite4_protosw); | 120 | inet_register_protosw(&udplite4_protosw); |
106 | 121 | ||
107 | #ifdef CONFIG_PROC_FS | 122 | if (udplite4_proc_init()) |
108 | if (udp_proc_register(&udplite4_seq_afinfo)) /* udplite4_proc_init() */ | 123 | printk(KERN_ERR "%s: Cannot register /proc!\n", __func__); |
109 | printk(KERN_ERR "%s: Cannot register /proc!\n", __FUNCTION__); | ||
110 | #endif | ||
111 | return; | 124 | return; |
112 | 125 | ||
113 | out_unregister_proto: | 126 | out_unregister_proto: |
114 | proto_unregister(&udplite_prot); | 127 | proto_unregister(&udplite_prot); |
115 | out_register_err: | 128 | out_register_err: |
116 | printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __FUNCTION__); | 129 | printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __func__); |
117 | } | 130 | } |
118 | 131 | ||
119 | EXPORT_SYMBOL(udplite_hash); | 132 | EXPORT_SYMBOL(udplite_hash); |
120 | EXPORT_SYMBOL(udplite_prot); | 133 | EXPORT_SYMBOL(udplite_prot); |
121 | EXPORT_SYMBOL(udplite_get_port); | ||