net/ipv4: UDP and generic UDP(-Lite) processing
Subsystems (3)
RFC PATCH 2/3 net/ipv4: UDP and generic UDP(-Lite) processing
[Net/IPv4]: Modifications to the UDP module and generic UDP/-Lite processing.
Signed-off-by Gerrit Renker <[email protected]>
---
include/net/udp.h | 72 +++++- net/ipv4/udp.c | 607 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 477 insertions(+), 202 deletions(-)
include/net/udp.h +67 -5
@@ -26,9 +26,48 @@ #include <linux/list.h>#include <net/inet_sock.h> #include <net/sock.h> #include <net/snmp.h> +#include <net/ip.h> +#include <linux/ipv6.h> #include <linux/seq_file.h> #define UDP_HTABLE_SIZE 128 +#include <net/udplite.h> + +/** +* struct udp_skb_cb - UDP(-Lite) private variables +* +* @header: private variables used by IPv4/IPv6 +* @cscov: checksum coverage length (UDP-Lite only) +* @partial_cov: if set indicates partial csum coverage +*/ +struct udp_skb_cb { +union { +struct inet_skb_parm h4; +#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +struct inet6_skb_parm h6; +#endif + } header; +__u16 cscov; +__u8 partial_cov; +}; +#define UDP_SKB_CB (__skb) ((struct udp_skb_cb *)((__skb)->cb)) + +/* +* Generic checksumming routines for UDP(-Lite) v4 and v6 +*/ +static inline u16 __udp_checksum_complete (struct sk_buff *skb) +{ +if (!UDP_SKB_CB (skb)->partial_cov) +return __skb_checksum_complete (skb); +return csum_fold (skb_checksum (skb,0 ,UDP_SKB_CB (skb)->cscov, + skb->csum)); +} + +static __inline__int udp_checksum_complete (struct sk_buff *skb) +{ +return skb->ip_summed !=CHECKSUM_UNNECESSARY && +__udp_checksum_complete (skb); +}/* udp.c: This needs to be shared by v4 and v6 because the lookup * and hashing code needs to work with different AF's yet
@@ -39,16 +78,25 @@ extern rwlock_t udp_hash_lock;extern int udp_port_rover; -static inline int udp_lport_inuse (u16 num) +/* +* XXX: the following two functions do not have to be here. The only +* other user of udp_lport_inuse is net/ipv6/udp.c -- whose get_port +* is almost fully identical with UDPv4's. -grrtrr +*/ +static inline int __udp_lport_inuse (u16 num,struct hlist_head udptable[]) {struct sock *sk;struct hlist_node *node; -sk_for_each (sk, node, &udp_hash[num & (UDP_HTABLE_SIZE -1 )]) +sk_for_each (sk, node, &udptable[num & (UDP_HTABLE_SIZE -1 )])if (inet_sk (sk)->num == num)return 1 ;return 0 ; } +static __inline__int udp_lport_inuse (u16 num) +{ +return __udp_lport_inuse (num, udp_hash); +}/* Note: this must match 'valbool' in sock_setsockopt */ #define UDP_CSUM_NOXMIT 1
@@ -75,21 +123,35 @@ extern unsigned int udp_poll(struct file poll_table *wait); DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); -#define UDP_INC_STATS (field) SNMP_INC_STATS(udp_statistics, field) -#define UDP_INC_STATS_BH (field) SNMP_INC_STATS_BH(udp_statistics, field) -#define UDP_INC_STATS_USER (field) SNMP_INC_STATS_USER(udp_statistics, field) +/* +* SNMP statistics for UDP and UDP-Lite +*/ +#define UDP_INC_STATS (field, is_udplite) \ + if (is_udplite) SNMP_INC_STATS(udplite_statistics, field); \ + else SNMP_INC_STATS(udp_statistics, field); +#define UDP_INC_STATS_USER (field, is_udplite) \ + if (is_udplite) SNMP_INC_STATS_USER(udplite_statistics, field); \ + else SNMP_INC_STATS_USER(udp_statistics, field); +#define UDP_INC_STATS_BH (field, is_udplite) \ + if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \ + else SNMP_INC_STATS_BH(udp_statistics, field); +#define UDP_DEC_STATS_BH (field, is_udplite) \ + if (is_udplite) SNMP_DEC_STATS_BH(udplite_statistics, field); \ + else SNMP_DEC_STATS_BH(udp_statistics, field);/* /proc */ struct udp_seq_afinfo {struct module *owner;char *name;sa_family_t family; +struct hlist_head *hashtable;int (*seq_show) (struct seq_file *m,void *v);struct file_operations *seq_fops; };struct udp_iter_state {sa_family_t family; +struct hlist_head *hashtable;int bucket;struct seq_operations seq_ops; };
net/ipv4/udp.c +410 -197
1,055 lines not on this page · raw message