提交 e898d4db 编写于 作者: Y YOSHIFUJI Hideaki

[UDP]: Allow users to configure UDP-Lite.

Let's give users an option for disabling UDP-Lite (~4K).

old:
|    text	   data	    bss	    dec	    hex	filename
|  286498	  12432	   6072	 305002	  4a76a	net/ipv4/built-in.o
|  193830	   8192	   3204	 205226	  321aa	net/ipv6/ipv6.o

new (without UDP-Lite):
|    text	   data	    bss	    dec	    hex	filename
|  284086	  12136	   5432	 301654	  49a56	net/ipv4/built-in.o
|  191835	   7832	   3076	 202743	  317f7	net/ipv6/ipv6.o
Signed-off-by: NYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
上级 c6aefafb
...@@ -70,8 +70,10 @@ struct udp_sock { ...@@ -70,8 +70,10 @@ struct udp_sock {
#define UDPLITE_BIT 0x1 /* set by udplite proto init function */ #define UDPLITE_BIT 0x1 /* set by udplite proto init function */
#define UDPLITE_SEND_CC 0x2 /* set via udplite setsockopt */ #define UDPLITE_SEND_CC 0x2 /* set via udplite setsockopt */
#define UDPLITE_RECV_CC 0x4 /* set via udplite setsocktopt */ #define UDPLITE_RECV_CC 0x4 /* set via udplite setsocktopt */
#ifdef CONFIG_IP_UDPLITE
__u8 pcflag; /* marks socket as UDP-Lite if > 0 */ __u8 pcflag; /* marks socket as UDP-Lite if > 0 */
__u8 unused[3]; __u8 unused[3];
#endif
/* /*
* For encapsulation sockets. * For encapsulation sockets.
*/ */
...@@ -82,7 +84,16 @@ static inline struct udp_sock *udp_sk(const struct sock *sk) ...@@ -82,7 +84,16 @@ static inline struct udp_sock *udp_sk(const struct sock *sk)
{ {
return (struct udp_sock *)sk; return (struct udp_sock *)sk;
} }
#ifdef CONFIG_IP_UDPLITE
#define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag) #define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag)
#define IS_PROTO_UDPLITE(__proto) ((__proto) == IPPROTO_UDPLITE)
#define IS_SOL_UDPFAMILY(level) ((level) == SOL_UDP || (level) == SOL_UDPLITE)
#else
#define IS_UDPLITE(__sk) 0
#define IS_PROTO_UDPLITE(__proto) 0
#define IS_SOL_UDPFAMILY(level) ((level) == SOL_UDP)
#endif
#endif #endif
......
...@@ -603,8 +603,13 @@ extern int tcp6_proc_init(void); ...@@ -603,8 +603,13 @@ extern int tcp6_proc_init(void);
extern void tcp6_proc_exit(void); extern void tcp6_proc_exit(void);
extern int udp6_proc_init(void); extern int udp6_proc_init(void);
extern void udp6_proc_exit(void); extern void udp6_proc_exit(void);
#ifdef CONFIG_IP_UDPLITE
extern int udplite6_proc_init(void); extern int udplite6_proc_init(void);
extern void udplite6_proc_exit(void); extern void udplite6_proc_exit(void);
#else
static inline int udplite6_proc_init(void) { return 0; }
static inline void udplite6_proc_exit(void) { }
#endif
extern int ipv6_misc_proc_init(void); extern int ipv6_misc_proc_init(void);
extern void ipv6_misc_proc_exit(void); extern void ipv6_misc_proc_exit(void);
extern int snmp6_register_dev(struct inet6_dev *idev); extern int snmp6_register_dev(struct inet6_dev *idev);
......
...@@ -27,8 +27,13 @@ extern int rawv6_init(void); ...@@ -27,8 +27,13 @@ extern int rawv6_init(void);
extern void rawv6_exit(void); extern void rawv6_exit(void);
extern int udpv6_init(void); extern int udpv6_init(void);
extern void udpv6_exit(void); extern void udpv6_exit(void);
#ifdef CONFIG_IP_UDPLITE
extern int udplitev6_init(void); extern int udplitev6_init(void);
extern void udplitev6_exit(void); extern void udplitev6_exit(void);
#else
static inline int udplitev6_init(void) { return 0; }
static inline void udplitev6_exit(void) { }
#endif
extern int tcpv6_init(void); extern int tcpv6_init(void);
extern void tcpv6_exit(void); extern void tcpv6_exit(void);
......
...@@ -25,7 +25,9 @@ static __inline__ int udplite_getfrag(void *from, char *to, int offset, ...@@ -25,7 +25,9 @@ static __inline__ int udplite_getfrag(void *from, char *to, int offset,
/* Designate sk as UDP-Lite socket */ /* Designate sk as UDP-Lite socket */
static inline int udplite_sk_init(struct sock *sk) static inline int udplite_sk_init(struct sock *sk)
{ {
#ifdef CONFIG_IP_UDPLITE
udp_sk(sk)->pcflag = UDPLITE_BIT; udp_sk(sk)->pcflag = UDPLITE_BIT;
#endif
return 0; return 0;
} }
...@@ -69,7 +71,7 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh) ...@@ -69,7 +71,7 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh)
static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh) static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh)
{ {
int cscov = up->len; int cscov = up->len;
#ifdef CONFIG_IP_UDPLITE
/* /*
* Sender has set `partial coverage' option on UDP-Lite socket * Sender has set `partial coverage' option on UDP-Lite socket
*/ */
...@@ -93,13 +95,15 @@ static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh) ...@@ -93,13 +95,15 @@ static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh)
* illegal, we fall back to the defaults here. * illegal, we fall back to the defaults here.
*/ */
} }
#endif
return cscov; return cscov;
} }
static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb) static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
{ {
int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb));
__wsum csum = 0; __wsum csum = 0;
#ifdef CONFIG_IP_UDPLITE
int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb));
skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */ skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */
...@@ -112,6 +116,7 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb) ...@@ -112,6 +116,7 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
if ((cscov -= len) <= 0) if ((cscov -= len) <= 0)
break; break;
} }
#endif
return csum; return csum;
} }
......
...@@ -632,5 +632,15 @@ config TCP_MD5SIG ...@@ -632,5 +632,15 @@ config TCP_MD5SIG
If unsure, say N. If unsure, say N.
config IP_UDPLITE
bool "IP: UDP-Lite Protocol (RFC 3828)"
default n
---help---
UDP-Lite (RFC 3828) is a UDP-like protocol with variable-length
checksum. Read <file:Documentation/networking/udplite.txt> for
details.
If unsure, say N.
source "net/ipv4/ipvs/Kconfig" source "net/ipv4/ipvs/Kconfig"
...@@ -8,7 +8,7 @@ obj-y := route.o inetpeer.o protocol.o \ ...@@ -8,7 +8,7 @@ obj-y := route.o inetpeer.o protocol.o \
inet_timewait_sock.o inet_connection_sock.o \ inet_timewait_sock.o inet_connection_sock.o \
tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
tcp_minisocks.o tcp_cong.o \ tcp_minisocks.o tcp_cong.o \
datagram.o raw.o udp.o udplite.o \ datagram.o raw.o udp.o \
arp.o icmp.o devinet.o af_inet.o igmp.o \ arp.o icmp.o devinet.o af_inet.o igmp.o \
fib_frontend.o fib_semantics.o \ fib_frontend.o fib_semantics.o \
inet_fragment.o inet_fragment.o
...@@ -49,6 +49,7 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o ...@@ -49,6 +49,7 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
obj-$(CONFIG_IP_UDPLITE) += udplite.o
obj-$(CONFIG_NETLABEL) += cipso_ipv4.o obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
......
...@@ -1317,15 +1317,18 @@ static int __init init_ipv4_mibs(void) ...@@ -1317,15 +1317,18 @@ static int __init init_ipv4_mibs(void)
if (snmp_mib_init((void **)udp_statistics, if (snmp_mib_init((void **)udp_statistics,
sizeof(struct udp_mib)) < 0) sizeof(struct udp_mib)) < 0)
goto err_udp_mib; goto err_udp_mib;
#ifdef CONFIG_IP_UDPLITE
if (snmp_mib_init((void **)udplite_statistics, if (snmp_mib_init((void **)udplite_statistics,
sizeof(struct udp_mib)) < 0) sizeof(struct udp_mib)) < 0)
goto err_udplite_mib; goto err_udplite_mib;
#endif
tcp_mib_init(); tcp_mib_init();
return 0; return 0;
#ifdef CONFIG_IP_UDPLITE
err_udplite_mib: err_udplite_mib:
#endif
snmp_mib_free((void **)udp_statistics); snmp_mib_free((void **)udp_statistics);
err_udp_mib: err_udp_mib:
snmp_mib_free((void **)tcp_statistics); snmp_mib_free((void **)tcp_statistics);
...@@ -1423,8 +1426,10 @@ static int __init inet_init(void) ...@@ -1423,8 +1426,10 @@ static int __init inet_init(void)
/* Setup UDP memory threshold */ /* Setup UDP memory threshold */
udp_init(); udp_init();
#ifdef CONFIG_IP_UDPLITE
/* Add UDP-Lite (RFC 3828) */ /* Add UDP-Lite (RFC 3828) */
udplite4_register(); udplite4_register();
#endif
/* /*
* Set the ICMP layer up * Set the ICMP layer up
......
...@@ -59,7 +59,9 @@ static int sockstat_seq_show(struct seq_file *seq, void *v) ...@@ -59,7 +59,9 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
atomic_read(&tcp_memory_allocated)); atomic_read(&tcp_memory_allocated));
seq_printf(seq, "UDP: inuse %d mem %d\n", sock_prot_inuse_get(&udp_prot), seq_printf(seq, "UDP: inuse %d mem %d\n", sock_prot_inuse_get(&udp_prot),
atomic_read(&udp_memory_allocated)); atomic_read(&udp_memory_allocated));
#ifdef CONFIG_IP_UDPLITE
seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse_get(&udplite_prot)); seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse_get(&udplite_prot));
#endif
seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse_get(&raw_prot)); seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse_get(&raw_prot));
seq_printf(seq, "FRAG: inuse %d memory %d\n", seq_printf(seq, "FRAG: inuse %d memory %d\n",
ip_frag_nqueues(&init_net), ip_frag_mem(&init_net)); ip_frag_nqueues(&init_net), ip_frag_mem(&init_net));
...@@ -349,6 +351,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v) ...@@ -349,6 +351,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
snmp_fold_field((void **)udp_statistics, snmp_fold_field((void **)udp_statistics,
snmp4_udp_list[i].entry)); snmp4_udp_list[i].entry));
#ifdef CONFIG_IP_UDPLITE
/* the UDP and UDP-Lite MIBs are the same */ /* the UDP and UDP-Lite MIBs are the same */
seq_puts(seq, "\nUdpLite:"); seq_puts(seq, "\nUdpLite:");
for (i = 0; snmp4_udp_list[i].name != NULL; i++) for (i = 0; snmp4_udp_list[i].name != NULL; i++)
...@@ -359,7 +362,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v) ...@@ -359,7 +362,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, " %lu", seq_printf(seq, " %lu",
snmp_fold_field((void **)udplite_statistics, snmp_fold_field((void **)udplite_statistics,
snmp4_udp_list[i].entry)); snmp4_udp_list[i].entry));
#endif
seq_putc(seq, '\n'); seq_putc(seq, '\n');
return 0; return 0;
} }
......
...@@ -1127,7 +1127,7 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh, ...@@ -1127,7 +1127,7 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
UDP_SKB_CB(skb)->partial_cov = 0; UDP_SKB_CB(skb)->partial_cov = 0;
UDP_SKB_CB(skb)->cscov = skb->len; UDP_SKB_CB(skb)->cscov = skb->len;
if (proto == IPPROTO_UDPLITE) { if (IS_PROTO_UDPLITE(proto)) {
err = udplite_checksum_init(skb, uh); err = udplite_checksum_init(skb, uh);
if (err) if (err)
return err; return err;
...@@ -1175,7 +1175,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -1175,7 +1175,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
if (ulen > skb->len) if (ulen > skb->len)
goto short_packet; goto short_packet;
if (proto == IPPROTO_UDP) { if (IS_PROTO_UDPLITE(proto)) {
/* UDP validates ulen. */ /* UDP validates ulen. */
if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen)) if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
goto short_packet; goto short_packet;
...@@ -1217,7 +1217,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -1217,7 +1217,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto csum_error; goto csum_error;
UDP_INC_STATS_BH(UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE); UDP_INC_STATS_BH(UDP_MIB_NOPORTS, IS_PROTO_UDPLITE(proto));
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
/* /*
...@@ -1229,7 +1229,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -1229,7 +1229,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
short_packet: short_packet:
LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %u.%u.%u.%u:%u %d/%d to %u.%u.%u.%u:%u\n", LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %u.%u.%u.%u:%u %d/%d to %u.%u.%u.%u:%u\n",
proto == IPPROTO_UDPLITE ? "-Lite" : "", IS_PROTO_UDPLITE(proto) ? "-Lite" : "",
NIPQUAD(saddr), NIPQUAD(saddr),
ntohs(uh->source), ntohs(uh->source),
ulen, ulen,
...@@ -1244,14 +1244,14 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -1244,14 +1244,14 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
* the network is concerned, anyway) as per 4.1.3.4 (MUST). * the network is concerned, anyway) as per 4.1.3.4 (MUST).
*/ */
LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n", LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n",
proto == IPPROTO_UDPLITE ? "-Lite" : "", IS_PROTO_UDPLITE(proto) ? "-Lite" : "",
NIPQUAD(saddr), NIPQUAD(saddr),
ntohs(uh->source), ntohs(uh->source),
NIPQUAD(daddr), NIPQUAD(daddr),
ntohs(uh->dest), ntohs(uh->dest),
ulen); ulen);
drop: drop:
UDP_INC_STATS_BH(UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); UDP_INC_STATS_BH(UDP_MIB_INERRORS, IS_PROTO_UDPLITE(proto));
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
...@@ -1279,7 +1279,9 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, ...@@ -1279,7 +1279,9 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
struct udp_sock *up = udp_sk(sk); struct udp_sock *up = udp_sk(sk);
int val; int val;
int err = 0; int err = 0;
#ifdef CONFIG_IP_UDPLITE
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
#endif
if (optlen<sizeof(int)) if (optlen<sizeof(int))
return -EINVAL; return -EINVAL;
...@@ -1315,6 +1317,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, ...@@ -1315,6 +1317,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
} }
break; break;
#ifdef CONFIG_IP_UDPLITE
/* /*
* UDP-Lite's partial checksum coverage (RFC 3828). * UDP-Lite's partial checksum coverage (RFC 3828).
*/ */
...@@ -1340,6 +1343,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, ...@@ -1340,6 +1343,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
up->pcrlen = val; up->pcrlen = val;
up->pcflag |= UDPLITE_RECV_CC; up->pcflag |= UDPLITE_RECV_CC;
break; break;
#endif
default: default:
err = -ENOPROTOOPT; err = -ENOPROTOOPT;
...@@ -1352,7 +1356,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, ...@@ -1352,7 +1356,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
int udp_setsockopt(struct sock *sk, int level, int optname, int udp_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, int optlen) char __user *optval, int optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_setsockopt(sk, level, optname, optval, optlen, return udp_lib_setsockopt(sk, level, optname, optval, optlen,
udp_push_pending_frames); udp_push_pending_frames);
return ip_setsockopt(sk, level, optname, optval, optlen); return ip_setsockopt(sk, level, optname, optval, optlen);
...@@ -1362,7 +1366,7 @@ int udp_setsockopt(struct sock *sk, int level, int optname, ...@@ -1362,7 +1366,7 @@ int udp_setsockopt(struct sock *sk, int level, int optname,
int compat_udp_setsockopt(struct sock *sk, int level, int optname, int compat_udp_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, int optlen) char __user *optval, int optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_setsockopt(sk, level, optname, optval, optlen, return udp_lib_setsockopt(sk, level, optname, optval, optlen,
udp_push_pending_frames); udp_push_pending_frames);
return compat_ip_setsockopt(sk, level, optname, optval, optlen); return compat_ip_setsockopt(sk, level, optname, optval, optlen);
...@@ -1416,7 +1420,7 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname, ...@@ -1416,7 +1420,7 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
int udp_getsockopt(struct sock *sk, int level, int optname, int udp_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_getsockopt(sk, level, optname, optval, optlen); return udp_lib_getsockopt(sk, level, optname, optval, optlen);
return ip_getsockopt(sk, level, optname, optval, optlen); return ip_getsockopt(sk, level, optname, optval, optlen);
} }
...@@ -1425,7 +1429,7 @@ int udp_getsockopt(struct sock *sk, int level, int optname, ...@@ -1425,7 +1429,7 @@ int udp_getsockopt(struct sock *sk, int level, int optname,
int compat_udp_getsockopt(struct sock *sk, int level, int optname, int compat_udp_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_getsockopt(sk, level, optname, optval, optlen); return udp_lib_getsockopt(sk, level, optname, optval, optlen);
return compat_ip_getsockopt(sk, level, optname, optval, optlen); return compat_ip_getsockopt(sk, level, optname, optval, optlen);
} }
......
...@@ -6,7 +6,7 @@ obj-$(CONFIG_IPV6) += ipv6.o ...@@ -6,7 +6,7 @@ obj-$(CONFIG_IPV6) += ipv6.o
ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \ ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
addrlabel.o \ addrlabel.o \
route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \ route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o \
raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o
...@@ -17,6 +17,7 @@ ipv6-$(CONFIG_NETFILTER) += netfilter.o ...@@ -17,6 +17,7 @@ ipv6-$(CONFIG_NETFILTER) += netfilter.o
ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o
ipv6-$(CONFIG_PROC_FS) += proc.o ipv6-$(CONFIG_PROC_FS) += proc.o
ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o
ipv6-$(CONFIG_IP_UDPLITE) += udplite.o
ipv6-objs += $(ipv6-y) ipv6-objs += $(ipv6-y)
......
...@@ -691,12 +691,16 @@ static int __init init_ipv6_mibs(void) ...@@ -691,12 +691,16 @@ static int __init init_ipv6_mibs(void)
goto err_icmpmsg_mib; goto err_icmpmsg_mib;
if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0) if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
goto err_udp_mib; goto err_udp_mib;
#ifdef CONFIG_IP_UDPLITE
if (snmp_mib_init((void **)udplite_stats_in6, if (snmp_mib_init((void **)udplite_stats_in6,
sizeof (struct udp_mib)) < 0) sizeof (struct udp_mib)) < 0)
goto err_udplite_mib; goto err_udplite_mib;
#endif
return 0; return 0;
#ifdef CONFIG_IP_UDPLITE
err_udplite_mib: err_udplite_mib:
#endif
snmp_mib_free((void **)udp_stats_in6); snmp_mib_free((void **)udp_stats_in6);
err_udp_mib: err_udp_mib:
snmp_mib_free((void **)icmpv6msg_statistics); snmp_mib_free((void **)icmpv6msg_statistics);
...@@ -715,7 +719,9 @@ static void cleanup_ipv6_mibs(void) ...@@ -715,7 +719,9 @@ static void cleanup_ipv6_mibs(void)
snmp_mib_free((void **)icmpv6_statistics); snmp_mib_free((void **)icmpv6_statistics);
snmp_mib_free((void **)icmpv6msg_statistics); snmp_mib_free((void **)icmpv6msg_statistics);
snmp_mib_free((void **)udp_stats_in6); snmp_mib_free((void **)udp_stats_in6);
#ifdef CONFIG_IP_UDPLITE
snmp_mib_free((void **)udplite_stats_in6); snmp_mib_free((void **)udplite_stats_in6);
#endif
} }
static int inet6_net_init(struct net *net) static int inet6_net_init(struct net *net)
...@@ -760,9 +766,11 @@ static int __init inet6_init(void) ...@@ -760,9 +766,11 @@ static int __init inet6_init(void)
if (err) if (err)
goto out_unregister_tcp_proto; goto out_unregister_tcp_proto;
#ifdef CONFIG_IP_UDPLITE
err = proto_register(&udplitev6_prot, 1); err = proto_register(&udplitev6_prot, 1);
if (err) if (err)
goto out_unregister_udp_proto; goto out_unregister_udp_proto;
#endif
err = proto_register(&rawv6_prot, 1); err = proto_register(&rawv6_prot, 1);
if (err) if (err)
...@@ -933,8 +941,10 @@ static int __init inet6_init(void) ...@@ -933,8 +941,10 @@ static int __init inet6_init(void)
out_unregister_raw_proto: out_unregister_raw_proto:
proto_unregister(&rawv6_prot); proto_unregister(&rawv6_prot);
out_unregister_udplite_proto: out_unregister_udplite_proto:
#ifdef CONFIG_IP_UDPLITE
proto_unregister(&udplitev6_prot); proto_unregister(&udplitev6_prot);
out_unregister_udp_proto: out_unregister_udp_proto:
#endif
proto_unregister(&udpv6_prot); proto_unregister(&udpv6_prot);
out_unregister_tcp_proto: out_unregister_tcp_proto:
proto_unregister(&tcpv6_prot); proto_unregister(&tcpv6_prot);
...@@ -950,7 +960,9 @@ static void __exit inet6_exit(void) ...@@ -950,7 +960,9 @@ static void __exit inet6_exit(void)
rtnl_unregister_all(PF_INET6); rtnl_unregister_all(PF_INET6);
udpv6_exit(); udpv6_exit();
#ifdef CONFIG_IP_UDPLITE
udplitev6_exit(); udplitev6_exit();
#endif
tcpv6_exit(); tcpv6_exit();
/* Cleanup code parts. */ /* Cleanup code parts. */
...@@ -982,7 +994,9 @@ static void __exit inet6_exit(void) ...@@ -982,7 +994,9 @@ static void __exit inet6_exit(void)
unregister_pernet_subsys(&inet6_net_ops); unregister_pernet_subsys(&inet6_net_ops);
cleanup_ipv6_mibs(); cleanup_ipv6_mibs();
proto_unregister(&rawv6_prot); proto_unregister(&rawv6_prot);
#ifdef CONFIG_IP_UDPLITE
proto_unregister(&udplitev6_prot); proto_unregister(&udplitev6_prot);
#endif
proto_unregister(&udpv6_prot); proto_unregister(&udpv6_prot);
proto_unregister(&tcpv6_prot); proto_unregister(&tcpv6_prot);
} }
......
...@@ -239,7 +239,9 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -239,7 +239,9 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
struct sk_buff *pktopt; struct sk_buff *pktopt;
if (sk->sk_protocol != IPPROTO_UDP && if (sk->sk_protocol != IPPROTO_UDP &&
#ifdef CONFIG_IP_UDPLITE
sk->sk_protocol != IPPROTO_UDPLITE && sk->sk_protocol != IPPROTO_UDPLITE &&
#endif
sk->sk_protocol != IPPROTO_TCP) sk->sk_protocol != IPPROTO_TCP)
break; break;
...@@ -279,7 +281,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -279,7 +281,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
} else { } else {
struct proto *prot = &udp_prot; struct proto *prot = &udp_prot;
if (sk->sk_protocol == IPPROTO_UDPLITE) if (IS_PROTO_UDPLITE(sk->sk_protocol))
prot = &udplite_prot; prot = &udplite_prot;
local_bh_disable(); local_bh_disable();
sock_prot_inuse_add(sk->sk_prot, -1); sock_prot_inuse_add(sk->sk_prot, -1);
...@@ -844,7 +846,9 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, ...@@ -844,7 +846,9 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
switch (optname) { switch (optname) {
case IPV6_ADDRFORM: case IPV6_ADDRFORM:
if (sk->sk_protocol != IPPROTO_UDP && if (sk->sk_protocol != IPPROTO_UDP &&
#ifdef CONFIG_IP_UDPLITE
sk->sk_protocol != IPPROTO_UDPLITE && sk->sk_protocol != IPPROTO_UDPLITE &&
#endif
sk->sk_protocol != IPPROTO_TCP) sk->sk_protocol != IPPROTO_TCP)
return -EINVAL; return -EINVAL;
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
......
...@@ -39,8 +39,10 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v) ...@@ -39,8 +39,10 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
sock_prot_inuse_get(&tcpv6_prot)); sock_prot_inuse_get(&tcpv6_prot));
seq_printf(seq, "UDP6: inuse %d\n", seq_printf(seq, "UDP6: inuse %d\n",
sock_prot_inuse_get(&udpv6_prot)); sock_prot_inuse_get(&udpv6_prot));
#ifdef CONFIG_IP_UDPLITE
seq_printf(seq, "UDPLITE6: inuse %d\n", seq_printf(seq, "UDPLITE6: inuse %d\n",
sock_prot_inuse_get(&udplitev6_prot)); sock_prot_inuse_get(&udplitev6_prot));
#endif
seq_printf(seq, "RAW6: inuse %d\n", seq_printf(seq, "RAW6: inuse %d\n",
sock_prot_inuse_get(&rawv6_prot)); sock_prot_inuse_get(&rawv6_prot));
seq_printf(seq, "FRAG6: inuse %d memory %d\n", seq_printf(seq, "FRAG6: inuse %d memory %d\n",
...@@ -111,6 +113,7 @@ static struct snmp_mib snmp6_udp6_list[] = { ...@@ -111,6 +113,7 @@ static struct snmp_mib snmp6_udp6_list[] = {
SNMP_MIB_SENTINEL SNMP_MIB_SENTINEL
}; };
#ifdef CONFIG_IP_UDPLITE
static struct snmp_mib snmp6_udplite6_list[] = { static struct snmp_mib snmp6_udplite6_list[] = {
SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS), SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS),
SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS), SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS),
...@@ -118,6 +121,7 @@ static struct snmp_mib snmp6_udplite6_list[] = { ...@@ -118,6 +121,7 @@ static struct snmp_mib snmp6_udplite6_list[] = {
SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS), SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
SNMP_MIB_SENTINEL SNMP_MIB_SENTINEL
}; };
#endif
static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
{ {
...@@ -176,7 +180,9 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) ...@@ -176,7 +180,9 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list);
snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics);
snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list);
#ifdef CONFIG_IP_UDPLITE
snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list);
#endif
} }
return 0; return 0;
} }
......
...@@ -400,7 +400,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, ...@@ -400,7 +400,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh,
UDP_SKB_CB(skb)->partial_cov = 0; UDP_SKB_CB(skb)->partial_cov = 0;
UDP_SKB_CB(skb)->cscov = skb->len; UDP_SKB_CB(skb)->cscov = skb->len;
if (proto == IPPROTO_UDPLITE) { if (IS_PROTO_UDPLITE(proto)) {
err = udplite_checksum_init(skb, uh); err = udplite_checksum_init(skb, uh);
if (err) if (err)
return err; return err;
...@@ -489,7 +489,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -489,7 +489,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto discard; goto discard;
UDP6_INC_STATS_BH(UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE); UDP6_INC_STATS_BH(UDP_MIB_NOPORTS, IS_PROTO_UDPLITE(proto));
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev); icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev);
...@@ -510,11 +510,11 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -510,11 +510,11 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
short_packet: short_packet:
LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n", LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n",
proto == IPPROTO_UDPLITE ? "-Lite" : "", IS_PROTO_UDPLITE(proto) ? "-Lite" : "",
ulen, skb->len); ulen, skb->len);
discard: discard:
UDP6_INC_STATS_BH(UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); UDP6_INC_STATS_BH(UDP_MIB_INERRORS, IS_PROTO_UDPLITE(proto));
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
...@@ -890,7 +890,7 @@ int udpv6_destroy_sock(struct sock *sk) ...@@ -890,7 +890,7 @@ int udpv6_destroy_sock(struct sock *sk)
int udpv6_setsockopt(struct sock *sk, int level, int optname, int udpv6_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, int optlen) char __user *optval, int optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_setsockopt(sk, level, optname, optval, optlen, return udp_lib_setsockopt(sk, level, optname, optval, optlen,
udp_v6_push_pending_frames); udp_v6_push_pending_frames);
return ipv6_setsockopt(sk, level, optname, optval, optlen); return ipv6_setsockopt(sk, level, optname, optval, optlen);
...@@ -900,7 +900,7 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -900,7 +900,7 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname,
int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, int optlen) char __user *optval, int optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_setsockopt(sk, level, optname, optval, optlen, return udp_lib_setsockopt(sk, level, optname, optval, optlen,
udp_v6_push_pending_frames); udp_v6_push_pending_frames);
return compat_ipv6_setsockopt(sk, level, optname, optval, optlen); return compat_ipv6_setsockopt(sk, level, optname, optval, optlen);
...@@ -910,7 +910,7 @@ int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -910,7 +910,7 @@ int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
int udpv6_getsockopt(struct sock *sk, int level, int optname, int udpv6_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_getsockopt(sk, level, optname, optval, optlen); return udp_lib_getsockopt(sk, level, optname, optval, optlen);
return ipv6_getsockopt(sk, level, optname, optval, optlen); return ipv6_getsockopt(sk, level, optname, optval, optlen);
} }
...@@ -919,7 +919,7 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname, ...@@ -919,7 +919,7 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname,
int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
if (level == SOL_UDP || level == SOL_UDPLITE) if (IS_SOL_UDPFAMILY(level))
return udp_lib_getsockopt(sk, level, optname, optval, optlen); return udp_lib_getsockopt(sk, level, optname, optval, optlen);
return compat_ipv6_getsockopt(sk, level, optname, optval, optlen); return compat_ipv6_getsockopt(sk, level, optname, optval, optlen);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册