Blame view

net/ipv4/udplite.c 3.45 KB
ba4e58eca   Gerrit Renker   [NET]: Supporting...
1
2
3
  /*
   *  UDPLITE     An implementation of the UDP-Lite protocol (RFC 3828).
   *
ba4e58eca   Gerrit Renker   [NET]: Supporting...
4
5
6
7
8
9
10
11
12
   *  Authors:    Gerrit Renker       <gerrit@erg.abdn.ac.uk>
   *
   *  Changes:
   *  Fixes:
   *		This program is free software; you can redistribute it and/or
   *		modify it under the terms of the GNU General Public License
   *		as published by the Free Software Foundation; either version
   *		2 of the License, or (at your option) any later version.
   */
afd465030   Joe Perches   net: ipv4: Standa...
13
14
  
  #define pr_fmt(fmt) "UDPLite: " fmt
bc3b2d7fb   Paul Gortmaker   net: Add export.h...
15
  #include <linux/export.h>
ba4e58eca   Gerrit Renker   [NET]: Supporting...
16
  #include "udp_impl.h"
ba4e58eca   Gerrit Renker   [NET]: Supporting...
17

f86dcc5aa   Eric Dumazet   udp: dynamically ...
18
  struct udp_table 	udplite_table __read_mostly;
645ca708f   Eric Dumazet   udp: introduce st...
19
  EXPORT_SYMBOL(udplite_table);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
20

f5b99bcdd   Adrian Bunk   [NET]: Possible c...
21
  static int udplite_rcv(struct sk_buff *skb)
ba4e58eca   Gerrit Renker   [NET]: Supporting...
22
  {
645ca708f   Eric Dumazet   udp: introduce st...
23
  	return __udp4_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
24
  }
f5b99bcdd   Adrian Bunk   [NET]: Possible c...
25
  static void udplite_err(struct sk_buff *skb, u32 info)
ba4e58eca   Gerrit Renker   [NET]: Supporting...
26
  {
645ca708f   Eric Dumazet   udp: introduce st...
27
  	__udp4_lib_err(skb, info, &udplite_table);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
28
  }
32613090a   Alexey Dobriyan   net: constify str...
29
  static const struct net_protocol udplite_protocol = {
ba4e58eca   Gerrit Renker   [NET]: Supporting...
30
31
32
  	.handler	= udplite_rcv,
  	.err_handler	= udplite_err,
  	.no_policy	= 1,
92f1fecb4   Denis V. Lunev   [NETNS]: Enable T...
33
  	.netns_ok	= 1,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  };
  
  struct proto 	udplite_prot = {
  	.name		   = "UDP-Lite",
  	.owner		   = THIS_MODULE,
  	.close		   = udp_lib_close,
  	.connect	   = ip4_datagram_connect,
  	.disconnect	   = udp_disconnect,
  	.ioctl		   = udp_ioctl,
  	.init		   = udplite_sk_init,
  	.destroy	   = udp_destroy_sock,
  	.setsockopt	   = udp_setsockopt,
  	.getsockopt	   = udp_getsockopt,
  	.sendmsg	   = udp_sendmsg,
  	.recvmsg	   = udp_recvmsg,
  	.sendpage	   = udp_sendpage,
  	.backlog_rcv	   = udp_queue_rcv_skb,
  	.hash		   = udp_lib_hash,
  	.unhash		   = udp_lib_unhash,
6ba5a3c52   Pavel Emelyanov   [UDP]: Make full ...
53
  	.get_port	   = udp_v4_get_port,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
54
  	.obj_size	   = sizeof(struct udp_sock),
271b72c7f   Eric Dumazet   udp: RCU handling...
55
  	.slab_flags	   = SLAB_DESTROY_BY_RCU,
645ca708f   Eric Dumazet   udp: introduce st...
56
  	.h.udp_table	   = &udplite_table,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
57
58
59
60
  #ifdef CONFIG_COMPAT
  	.compat_setsockopt = compat_udp_setsockopt,
  	.compat_getsockopt = compat_udp_getsockopt,
  #endif
fcbdf09d9   Octavian Purdila   net: fix nulls li...
61
  	.clear_sk	   = sk_prot_clear_portaddr_nulls,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
62
  };
4bc2f18ba   Eric Dumazet   net/ipv4: EXPORT_...
63
  EXPORT_SYMBOL(udplite_prot);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
64
65
66
67
68
69
  
  static struct inet_protosw udplite4_protosw = {
  	.type		=  SOCK_DGRAM,
  	.protocol	=  IPPROTO_UDPLITE,
  	.prot		=  &udplite_prot,
  	.ops		=  &inet_dgram_ops,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
70
71
72
73
74
  	.no_check	=  0,		/* must checksum (RFC 3828) */
  	.flags		=  INET_PROTOSW_PERMANENT,
  };
  
  #ifdef CONFIG_PROC_FS
73cb88ecb   Arjan van de Ven   net: make the tcp...
75
76
77
78
79
80
81
82
  
  static const struct file_operations udplite_afinfo_seq_fops = {
  	.owner    = THIS_MODULE,
  	.open     = udp_seq_open,
  	.read     = seq_read,
  	.llseek   = seq_lseek,
  	.release  = seq_release_net
  };
ba4e58eca   Gerrit Renker   [NET]: Supporting...
83
  static struct udp_seq_afinfo udplite4_seq_afinfo = {
ba4e58eca   Gerrit Renker   [NET]: Supporting...
84
85
  	.name		= "udplite",
  	.family		= AF_INET,
645ca708f   Eric Dumazet   udp: introduce st...
86
  	.udp_table 	= &udplite_table,
73cb88ecb   Arjan van de Ven   net: make the tcp...
87
  	.seq_fops	= &udplite_afinfo_seq_fops,
dda61925f   Denis V. Lunev   [UDP]: Move seq_o...
88
89
90
  	.seq_ops	= {
  		.show		= udp4_seq_show,
  	},
ba4e58eca   Gerrit Renker   [NET]: Supporting...
91
  };
ff2bac6a6   Pavel Emelyanov   [UDP-Lite]: Clean...
92

2c8c1e729   Alexey Dobriyan   net: spread __net...
93
  static int __net_init udplite4_proc_init_net(struct net *net)
84c375af0   Pavel Emelyanov   [NETNS][UDP-Lite]...
94
95
96
  {
  	return udp_proc_register(net, &udplite4_seq_afinfo);
  }
2c8c1e729   Alexey Dobriyan   net: spread __net...
97
  static void __net_exit udplite4_proc_exit_net(struct net *net)
84c375af0   Pavel Emelyanov   [NETNS][UDP-Lite]...
98
99
100
101
102
103
104
105
  {
  	udp_proc_unregister(net, &udplite4_seq_afinfo);
  }
  
  static struct pernet_operations udplite4_net_ops = {
  	.init = udplite4_proc_init_net,
  	.exit = udplite4_proc_exit_net,
  };
ff2bac6a6   Pavel Emelyanov   [UDP-Lite]: Clean...
106
107
  static __init int udplite4_proc_init(void)
  {
84c375af0   Pavel Emelyanov   [NETNS][UDP-Lite]...
108
  	return register_pernet_subsys(&udplite4_net_ops);
ff2bac6a6   Pavel Emelyanov   [UDP-Lite]: Clean...
109
110
111
112
113
114
  }
  #else
  static inline int udplite4_proc_init(void)
  {
  	return 0;
  }
ba4e58eca   Gerrit Renker   [NET]: Supporting...
115
116
117
118
  #endif
  
  void __init udplite4_register(void)
  {
f86dcc5aa   Eric Dumazet   udp: dynamically ...
119
  	udp_table_init(&udplite_table, "UDP-Lite");
ba4e58eca   Gerrit Renker   [NET]: Supporting...
120
121
122
123
124
125
126
  	if (proto_register(&udplite_prot, 1))
  		goto out_register_err;
  
  	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
  		goto out_unregister_proto;
  
  	inet_register_protosw(&udplite4_protosw);
ff2bac6a6   Pavel Emelyanov   [UDP-Lite]: Clean...
127
  	if (udplite4_proc_init())
058bd4d2a   Joe Perches   net: Convert prin...
128
129
  		pr_err("%s: Cannot register /proc!
  ", __func__);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
130
131
132
133
134
  	return;
  
  out_unregister_proto:
  	proto_unregister(&udplite_prot);
  out_register_err:
058bd4d2a   Joe Perches   net: Convert prin...
135
136
  	pr_crit("%s: Cannot add UDP-Lite protocol
  ", __func__);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
137
  }