Blame view

net/ipv4/udplite.c 3.32 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
  };
  
  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,
30c7be26f   Eric Dumazet   udplite: call pro...
50
  	.backlog_rcv	   = __udp_queue_rcv_skb,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
51
52
  	.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),
645ca708f   Eric Dumazet   udp: introduce st...
55
  	.h.udp_table	   = &udplite_table,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
56
57
58
59
60
  #ifdef CONFIG_COMPAT
  	.compat_setsockopt = compat_udp_setsockopt,
  	.compat_getsockopt = compat_udp_getsockopt,
  #endif
  };
4bc2f18ba   Eric Dumazet   net/ipv4: EXPORT_...
61
  EXPORT_SYMBOL(udplite_prot);
ba4e58eca   Gerrit Renker   [NET]: Supporting...
62
63
64
65
66
67
  
  static struct inet_protosw udplite4_protosw = {
  	.type		=  SOCK_DGRAM,
  	.protocol	=  IPPROTO_UDPLITE,
  	.prot		=  &udplite_prot,
  	.ops		=  &inet_dgram_ops,
ba4e58eca   Gerrit Renker   [NET]: Supporting...
68
69
70
71
  	.flags		=  INET_PROTOSW_PERMANENT,
  };
  
  #ifdef CONFIG_PROC_FS
73cb88ecb   Arjan van de Ven   net: make the tcp...
72
73
74
75
76
77
78
79
  
  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...
80
  static struct udp_seq_afinfo udplite4_seq_afinfo = {
ba4e58eca   Gerrit Renker   [NET]: Supporting...
81
82
  	.name		= "udplite",
  	.family		= AF_INET,
645ca708f   Eric Dumazet   udp: introduce st...
83
  	.udp_table 	= &udplite_table,
73cb88ecb   Arjan van de Ven   net: make the tcp...
84
  	.seq_fops	= &udplite_afinfo_seq_fops,
dda61925f   Denis V. Lunev   [UDP]: Move seq_o...
85
86
87
  	.seq_ops	= {
  		.show		= udp4_seq_show,
  	},
ba4e58eca   Gerrit Renker   [NET]: Supporting...
88
  };
ff2bac6a6   Pavel Emelyanov   [UDP-Lite]: Clean...
89

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