summaryrefslogtreecommitdiff
path: root/net/ipv6
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-01 01:06:47 +0900
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-04 15:18:22 +0900
commite898d4db2749c6052072e9bc4448e396cbdeb06a (patch)
tree2b8673d85210a23e67d0817b18f401411e8936f3 /net/ipv6
parentc6aefafb7ec620911d46174eed514f9df639e5a4 (diff)
downloadlinux-3.10-e898d4db2749c6052072e9bc4448e396cbdeb06a.tar.gz
linux-3.10-e898d4db2749c6052072e9bc4448e396cbdeb06a.tar.bz2
linux-3.10-e898d4db2749c6052072e9bc4448e396cbdeb06a.zip
[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: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/Makefile3
-rw-r--r--net/ipv6/af_inet6.c14
-rw-r--r--net/ipv6/ipv6_sockglue.c6
-rw-r--r--net/ipv6/proc.c6
-rw-r--r--net/ipv6/udp.c16
5 files changed, 35 insertions, 10 deletions
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index ae14617e607..81969479955 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -6,7 +6,7 @@ obj-$(CONFIG_IPV6) += ipv6.o
ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.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 \
exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o
@@ -17,6 +17,7 @@ ipv6-$(CONFIG_NETFILTER) += netfilter.o
ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o
ipv6-$(CONFIG_PROC_FS) += proc.o
ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o
+ipv6-$(CONFIG_IP_UDPLITE) += udplite.o
ipv6-objs += $(ipv6-y)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 9869f87243c..243c42a6b80 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -691,12 +691,16 @@ static int __init init_ipv6_mibs(void)
goto err_icmpmsg_mib;
if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
goto err_udp_mib;
+#ifdef CONFIG_IP_UDPLITE
if (snmp_mib_init((void **)udplite_stats_in6,
sizeof (struct udp_mib)) < 0)
goto err_udplite_mib;
+#endif
return 0;
+#ifdef CONFIG_IP_UDPLITE
err_udplite_mib:
+#endif
snmp_mib_free((void **)udp_stats_in6);
err_udp_mib:
snmp_mib_free((void **)icmpv6msg_statistics);
@@ -715,7 +719,9 @@ static void cleanup_ipv6_mibs(void)
snmp_mib_free((void **)icmpv6_statistics);
snmp_mib_free((void **)icmpv6msg_statistics);
snmp_mib_free((void **)udp_stats_in6);
+#ifdef CONFIG_IP_UDPLITE
snmp_mib_free((void **)udplite_stats_in6);
+#endif
}
static int inet6_net_init(struct net *net)
@@ -760,9 +766,11 @@ static int __init inet6_init(void)
if (err)
goto out_unregister_tcp_proto;
+#ifdef CONFIG_IP_UDPLITE
err = proto_register(&udplitev6_prot, 1);
if (err)
goto out_unregister_udp_proto;
+#endif
err = proto_register(&rawv6_prot, 1);
if (err)
@@ -933,8 +941,10 @@ out_sock_register_fail:
out_unregister_raw_proto:
proto_unregister(&rawv6_prot);
out_unregister_udplite_proto:
+#ifdef CONFIG_IP_UDPLITE
proto_unregister(&udplitev6_prot);
out_unregister_udp_proto:
+#endif
proto_unregister(&udpv6_prot);
out_unregister_tcp_proto:
proto_unregister(&tcpv6_prot);
@@ -950,7 +960,9 @@ static void __exit inet6_exit(void)
rtnl_unregister_all(PF_INET6);
udpv6_exit();
+#ifdef CONFIG_IP_UDPLITE
udplitev6_exit();
+#endif
tcpv6_exit();
/* Cleanup code parts. */
@@ -982,7 +994,9 @@ static void __exit inet6_exit(void)
unregister_pernet_subsys(&inet6_net_ops);
cleanup_ipv6_mibs();
proto_unregister(&rawv6_prot);
+#ifdef CONFIG_IP_UDPLITE
proto_unregister(&udplitev6_prot);
+#endif
proto_unregister(&udpv6_prot);
proto_unregister(&tcpv6_prot);
}
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index bf2a686aa13..0a18fecb93d 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -239,7 +239,9 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
struct sk_buff *pktopt;
if (sk->sk_protocol != IPPROTO_UDP &&
+#ifdef CONFIG_IP_UDPLITE
sk->sk_protocol != IPPROTO_UDPLITE &&
+#endif
sk->sk_protocol != IPPROTO_TCP)
break;
@@ -279,7 +281,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
} else {
struct proto *prot = &udp_prot;
- if (sk->sk_protocol == IPPROTO_UDPLITE)
+ if (IS_PROTO_UDPLITE(sk->sk_protocol))
prot = &udplite_prot;
local_bh_disable();
sock_prot_inuse_add(sk->sk_prot, -1);
@@ -844,7 +846,9 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
switch (optname) {
case IPV6_ADDRFORM:
if (sk->sk_protocol != IPPROTO_UDP &&
+#ifdef CONFIG_IP_UDPLITE
sk->sk_protocol != IPPROTO_UDPLITE &&
+#endif
sk->sk_protocol != IPPROTO_TCP)
return -EINVAL;
if (sk->sk_state != TCP_ESTABLISHED)
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 199ef379e50..5ba7ae849d0 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -39,8 +39,10 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
sock_prot_inuse_get(&tcpv6_prot));
seq_printf(seq, "UDP6: inuse %d\n",
sock_prot_inuse_get(&udpv6_prot));
+#ifdef CONFIG_IP_UDPLITE
seq_printf(seq, "UDPLITE6: inuse %d\n",
sock_prot_inuse_get(&udplitev6_prot));
+#endif
seq_printf(seq, "RAW6: inuse %d\n",
sock_prot_inuse_get(&rawv6_prot));
seq_printf(seq, "FRAG6: inuse %d memory %d\n",
@@ -111,6 +113,7 @@ static struct snmp_mib snmp6_udp6_list[] = {
SNMP_MIB_SENTINEL
};
+#ifdef CONFIG_IP_UDPLITE
static struct snmp_mib snmp6_udplite6_list[] = {
SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS),
SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS),
@@ -118,6 +121,7 @@ static struct snmp_mib snmp6_udplite6_list[] = {
SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
SNMP_MIB_SENTINEL
};
+#endif
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)
snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list);
snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics);
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);
+#endif
}
return 0;
}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 53739de829d..55feac7ba71 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -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)->cscov = skb->len;
- if (proto == IPPROTO_UDPLITE) {
+ if (IS_PROTO_UDPLITE(proto)) {
err = udplite_checksum_init(skb, uh);
if (err)
return err;
@@ -489,7 +489,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
if (udp_lib_checksum_complete(skb))
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);
@@ -510,11 +510,11 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
short_packet:
LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n",
- proto == IPPROTO_UDPLITE ? "-Lite" : "",
+ IS_PROTO_UDPLITE(proto) ? "-Lite" : "",
ulen, skb->len);
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);
return 0;
}
@@ -890,7 +890,7 @@ int udpv6_destroy_sock(struct sock *sk)
int udpv6_setsockopt(struct sock *sk, int level, int optname,
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,
udp_v6_push_pending_frames);
return ipv6_setsockopt(sk, level, optname, optval, optlen);
@@ -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,
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,
udp_v6_push_pending_frames);
return compat_ipv6_setsockopt(sk, level, optname, optval, optlen);
@@ -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,
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 ipv6_getsockopt(sk, level, optname, optval, optlen);
}
@@ -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,
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 compat_ipv6_getsockopt(sk, level, optname, optval, optlen);
}