diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-02-29 11:06:47 -0500 |
---|---|---|
committer | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-04 01:18:22 -0500 |
commit | e898d4db2749c6052072e9bc4448e396cbdeb06a (patch) | |
tree | 2b8673d85210a23e67d0817b18f401411e8936f3 /net/ipv6 | |
parent | c6aefafb7ec620911d46174eed514f9df639e5a4 (diff) |
[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/Makefile | 3 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 14 | ||||
-rw-r--r-- | net/ipv6/ipv6_sockglue.c | 6 | ||||
-rw-r--r-- | net/ipv6/proc.c | 6 | ||||
-rw-r--r-- | net/ipv6/udp.c | 16 |
5 files changed, 35 insertions, 10 deletions
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile index ae14617e607f..81969479955f 100644 --- a/net/ipv6/Makefile +++ b/net/ipv6/Makefile | |||
@@ -6,7 +6,7 @@ obj-$(CONFIG_IPV6) += ipv6.o | |||
6 | 6 | ||
7 | ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \ | 7 | ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \ |
8 | addrlabel.o \ | 8 | addrlabel.o \ |
9 | route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \ | 9 | route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o \ |
10 | raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ | 10 | raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ |
11 | exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o | 11 | exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o |
12 | 12 | ||
@@ -17,6 +17,7 @@ ipv6-$(CONFIG_NETFILTER) += netfilter.o | |||
17 | ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o | 17 | ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o |
18 | ipv6-$(CONFIG_PROC_FS) += proc.o | 18 | ipv6-$(CONFIG_PROC_FS) += proc.o |
19 | ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o | 19 | ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o |
20 | ipv6-$(CONFIG_IP_UDPLITE) += udplite.o | ||
20 | 21 | ||
21 | ipv6-objs += $(ipv6-y) | 22 | ipv6-objs += $(ipv6-y) |
22 | 23 | ||
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 9869f87243cf..243c42a6b80d 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -691,12 +691,16 @@ static int __init init_ipv6_mibs(void) | |||
691 | goto err_icmpmsg_mib; | 691 | goto err_icmpmsg_mib; |
692 | if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0) | 692 | if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0) |
693 | goto err_udp_mib; | 693 | goto err_udp_mib; |
694 | #ifdef CONFIG_IP_UDPLITE | ||
694 | if (snmp_mib_init((void **)udplite_stats_in6, | 695 | if (snmp_mib_init((void **)udplite_stats_in6, |
695 | sizeof (struct udp_mib)) < 0) | 696 | sizeof (struct udp_mib)) < 0) |
696 | goto err_udplite_mib; | 697 | goto err_udplite_mib; |
698 | #endif | ||
697 | return 0; | 699 | return 0; |
698 | 700 | ||
701 | #ifdef CONFIG_IP_UDPLITE | ||
699 | err_udplite_mib: | 702 | err_udplite_mib: |
703 | #endif | ||
700 | snmp_mib_free((void **)udp_stats_in6); | 704 | snmp_mib_free((void **)udp_stats_in6); |
701 | err_udp_mib: | 705 | err_udp_mib: |
702 | snmp_mib_free((void **)icmpv6msg_statistics); | 706 | snmp_mib_free((void **)icmpv6msg_statistics); |
@@ -715,7 +719,9 @@ static void cleanup_ipv6_mibs(void) | |||
715 | snmp_mib_free((void **)icmpv6_statistics); | 719 | snmp_mib_free((void **)icmpv6_statistics); |
716 | snmp_mib_free((void **)icmpv6msg_statistics); | 720 | snmp_mib_free((void **)icmpv6msg_statistics); |
717 | snmp_mib_free((void **)udp_stats_in6); | 721 | snmp_mib_free((void **)udp_stats_in6); |
722 | #ifdef CONFIG_IP_UDPLITE | ||
718 | snmp_mib_free((void **)udplite_stats_in6); | 723 | snmp_mib_free((void **)udplite_stats_in6); |
724 | #endif | ||
719 | } | 725 | } |
720 | 726 | ||
721 | static int inet6_net_init(struct net *net) | 727 | static int inet6_net_init(struct net *net) |
@@ -760,9 +766,11 @@ static int __init inet6_init(void) | |||
760 | if (err) | 766 | if (err) |
761 | goto out_unregister_tcp_proto; | 767 | goto out_unregister_tcp_proto; |
762 | 768 | ||
769 | #ifdef CONFIG_IP_UDPLITE | ||
763 | err = proto_register(&udplitev6_prot, 1); | 770 | err = proto_register(&udplitev6_prot, 1); |
764 | if (err) | 771 | if (err) |
765 | goto out_unregister_udp_proto; | 772 | goto out_unregister_udp_proto; |
773 | #endif | ||
766 | 774 | ||
767 | err = proto_register(&rawv6_prot, 1); | 775 | err = proto_register(&rawv6_prot, 1); |
768 | if (err) | 776 | if (err) |
@@ -933,8 +941,10 @@ out_sock_register_fail: | |||
933 | out_unregister_raw_proto: | 941 | out_unregister_raw_proto: |
934 | proto_unregister(&rawv6_prot); | 942 | proto_unregister(&rawv6_prot); |
935 | out_unregister_udplite_proto: | 943 | out_unregister_udplite_proto: |
944 | #ifdef CONFIG_IP_UDPLITE | ||
936 | proto_unregister(&udplitev6_prot); | 945 | proto_unregister(&udplitev6_prot); |
937 | out_unregister_udp_proto: | 946 | out_unregister_udp_proto: |
947 | #endif | ||
938 | proto_unregister(&udpv6_prot); | 948 | proto_unregister(&udpv6_prot); |
939 | out_unregister_tcp_proto: | 949 | out_unregister_tcp_proto: |
940 | proto_unregister(&tcpv6_prot); | 950 | proto_unregister(&tcpv6_prot); |
@@ -950,7 +960,9 @@ static void __exit inet6_exit(void) | |||
950 | rtnl_unregister_all(PF_INET6); | 960 | rtnl_unregister_all(PF_INET6); |
951 | 961 | ||
952 | udpv6_exit(); | 962 | udpv6_exit(); |
963 | #ifdef CONFIG_IP_UDPLITE | ||
953 | udplitev6_exit(); | 964 | udplitev6_exit(); |
965 | #endif | ||
954 | tcpv6_exit(); | 966 | tcpv6_exit(); |
955 | 967 | ||
956 | /* Cleanup code parts. */ | 968 | /* Cleanup code parts. */ |
@@ -982,7 +994,9 @@ static void __exit inet6_exit(void) | |||
982 | unregister_pernet_subsys(&inet6_net_ops); | 994 | unregister_pernet_subsys(&inet6_net_ops); |
983 | cleanup_ipv6_mibs(); | 995 | cleanup_ipv6_mibs(); |
984 | proto_unregister(&rawv6_prot); | 996 | proto_unregister(&rawv6_prot); |
997 | #ifdef CONFIG_IP_UDPLITE | ||
985 | proto_unregister(&udplitev6_prot); | 998 | proto_unregister(&udplitev6_prot); |
999 | #endif | ||
986 | proto_unregister(&udpv6_prot); | 1000 | proto_unregister(&udpv6_prot); |
987 | proto_unregister(&tcpv6_prot); | 1001 | proto_unregister(&tcpv6_prot); |
988 | } | 1002 | } |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index bf2a686aa13d..0a18fecb93d1 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, | |||
239 | struct sk_buff *pktopt; | 239 | struct sk_buff *pktopt; |
240 | 240 | ||
241 | if (sk->sk_protocol != IPPROTO_UDP && | 241 | if (sk->sk_protocol != IPPROTO_UDP && |
242 | #ifdef CONFIG_IP_UDPLITE | ||
242 | sk->sk_protocol != IPPROTO_UDPLITE && | 243 | sk->sk_protocol != IPPROTO_UDPLITE && |
244 | #endif | ||
243 | sk->sk_protocol != IPPROTO_TCP) | 245 | sk->sk_protocol != IPPROTO_TCP) |
244 | break; | 246 | break; |
245 | 247 | ||
@@ -279,7 +281,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
279 | } else { | 281 | } else { |
280 | struct proto *prot = &udp_prot; | 282 | struct proto *prot = &udp_prot; |
281 | 283 | ||
282 | if (sk->sk_protocol == IPPROTO_UDPLITE) | 284 | if (IS_PROTO_UDPLITE(sk->sk_protocol)) |
283 | prot = &udplite_prot; | 285 | prot = &udplite_prot; |
284 | local_bh_disable(); | 286 | local_bh_disable(); |
285 | sock_prot_inuse_add(sk->sk_prot, -1); | 287 | 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 | switch (optname) { | 846 | switch (optname) { |
845 | case IPV6_ADDRFORM: | 847 | case IPV6_ADDRFORM: |
846 | if (sk->sk_protocol != IPPROTO_UDP && | 848 | if (sk->sk_protocol != IPPROTO_UDP && |
849 | #ifdef CONFIG_IP_UDPLITE | ||
847 | sk->sk_protocol != IPPROTO_UDPLITE && | 850 | sk->sk_protocol != IPPROTO_UDPLITE && |
851 | #endif | ||
848 | sk->sk_protocol != IPPROTO_TCP) | 852 | sk->sk_protocol != IPPROTO_TCP) |
849 | return -EINVAL; | 853 | return -EINVAL; |
850 | if (sk->sk_state != TCP_ESTABLISHED) | 854 | if (sk->sk_state != TCP_ESTABLISHED) |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 199ef379e501..5ba7ae849d04 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) | |||
39 | sock_prot_inuse_get(&tcpv6_prot)); | 39 | sock_prot_inuse_get(&tcpv6_prot)); |
40 | seq_printf(seq, "UDP6: inuse %d\n", | 40 | seq_printf(seq, "UDP6: inuse %d\n", |
41 | sock_prot_inuse_get(&udpv6_prot)); | 41 | sock_prot_inuse_get(&udpv6_prot)); |
42 | #ifdef CONFIG_IP_UDPLITE | ||
42 | seq_printf(seq, "UDPLITE6: inuse %d\n", | 43 | seq_printf(seq, "UDPLITE6: inuse %d\n", |
43 | sock_prot_inuse_get(&udplitev6_prot)); | 44 | sock_prot_inuse_get(&udplitev6_prot)); |
45 | #endif | ||
44 | seq_printf(seq, "RAW6: inuse %d\n", | 46 | seq_printf(seq, "RAW6: inuse %d\n", |
45 | sock_prot_inuse_get(&rawv6_prot)); | 47 | sock_prot_inuse_get(&rawv6_prot)); |
46 | seq_printf(seq, "FRAG6: inuse %d memory %d\n", | 48 | seq_printf(seq, "FRAG6: inuse %d memory %d\n", |
@@ -111,6 +113,7 @@ static struct snmp_mib snmp6_udp6_list[] = { | |||
111 | SNMP_MIB_SENTINEL | 113 | SNMP_MIB_SENTINEL |
112 | }; | 114 | }; |
113 | 115 | ||
116 | #ifdef CONFIG_IP_UDPLITE | ||
114 | static struct snmp_mib snmp6_udplite6_list[] = { | 117 | static struct snmp_mib snmp6_udplite6_list[] = { |
115 | SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS), | 118 | SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS), |
116 | SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS), | 119 | SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS), |
@@ -118,6 +121,7 @@ static struct snmp_mib snmp6_udplite6_list[] = { | |||
118 | SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS), | 121 | SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS), |
119 | SNMP_MIB_SENTINEL | 122 | SNMP_MIB_SENTINEL |
120 | }; | 123 | }; |
124 | #endif | ||
121 | 125 | ||
122 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) | 126 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) |
123 | { | 127 | { |
@@ -176,7 +180,9 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) | |||
176 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); | 180 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); |
177 | snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); | 181 | snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); |
178 | snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); | 182 | snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); |
183 | #ifdef CONFIG_IP_UDPLITE | ||
179 | snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); | 184 | snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); |
185 | #endif | ||
180 | } | 186 | } |
181 | return 0; | 187 | return 0; |
182 | } | 188 | } |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 53739de829db..55feac7ba717 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, | |||
400 | UDP_SKB_CB(skb)->partial_cov = 0; | 400 | UDP_SKB_CB(skb)->partial_cov = 0; |
401 | UDP_SKB_CB(skb)->cscov = skb->len; | 401 | UDP_SKB_CB(skb)->cscov = skb->len; |
402 | 402 | ||
403 | if (proto == IPPROTO_UDPLITE) { | 403 | if (IS_PROTO_UDPLITE(proto)) { |
404 | err = udplite_checksum_init(skb, uh); | 404 | err = udplite_checksum_init(skb, uh); |
405 | if (err) | 405 | if (err) |
406 | return err; | 406 | return err; |
@@ -489,7 +489,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
489 | 489 | ||
490 | if (udp_lib_checksum_complete(skb)) | 490 | if (udp_lib_checksum_complete(skb)) |
491 | goto discard; | 491 | goto discard; |
492 | UDP6_INC_STATS_BH(UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE); | 492 | UDP6_INC_STATS_BH(UDP_MIB_NOPORTS, IS_PROTO_UDPLITE(proto)); |
493 | 493 | ||
494 | icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev); | 494 | icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev); |
495 | 495 | ||
@@ -510,11 +510,11 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
510 | 510 | ||
511 | short_packet: | 511 | short_packet: |
512 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n", | 512 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n", |
513 | proto == IPPROTO_UDPLITE ? "-Lite" : "", | 513 | IS_PROTO_UDPLITE(proto) ? "-Lite" : "", |
514 | ulen, skb->len); | 514 | ulen, skb->len); |
515 | 515 | ||
516 | discard: | 516 | discard: |
517 | UDP6_INC_STATS_BH(UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); | 517 | UDP6_INC_STATS_BH(UDP_MIB_INERRORS, IS_PROTO_UDPLITE(proto)); |
518 | kfree_skb(skb); | 518 | kfree_skb(skb); |
519 | return 0; | 519 | return 0; |
520 | } | 520 | } |
@@ -890,7 +890,7 @@ int udpv6_destroy_sock(struct sock *sk) | |||
890 | int udpv6_setsockopt(struct sock *sk, int level, int optname, | 890 | int udpv6_setsockopt(struct sock *sk, int level, int optname, |
891 | char __user *optval, int optlen) | 891 | char __user *optval, int optlen) |
892 | { | 892 | { |
893 | if (level == SOL_UDP || level == SOL_UDPLITE) | 893 | if (IS_SOL_UDPFAMILY(level)) |
894 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, | 894 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, |
895 | udp_v6_push_pending_frames); | 895 | udp_v6_push_pending_frames); |
896 | return ipv6_setsockopt(sk, level, optname, optval, optlen); | 896 | return ipv6_setsockopt(sk, level, optname, optval, optlen); |
@@ -900,7 +900,7 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, | |||
900 | int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, | 900 | int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, |
901 | char __user *optval, int optlen) | 901 | char __user *optval, int optlen) |
902 | { | 902 | { |
903 | if (level == SOL_UDP || level == SOL_UDPLITE) | 903 | if (IS_SOL_UDPFAMILY(level)) |
904 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, | 904 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, |
905 | udp_v6_push_pending_frames); | 905 | udp_v6_push_pending_frames); |
906 | return compat_ipv6_setsockopt(sk, level, optname, optval, optlen); | 906 | 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 | int udpv6_getsockopt(struct sock *sk, int level, int optname, | 910 | int udpv6_getsockopt(struct sock *sk, int level, int optname, |
911 | char __user *optval, int __user *optlen) | 911 | char __user *optval, int __user *optlen) |
912 | { | 912 | { |
913 | if (level == SOL_UDP || level == SOL_UDPLITE) | 913 | if (IS_SOL_UDPFAMILY(level)) |
914 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); | 914 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); |
915 | return ipv6_getsockopt(sk, level, optname, optval, optlen); | 915 | return ipv6_getsockopt(sk, level, optname, optval, optlen); |
916 | } | 916 | } |
@@ -919,7 +919,7 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname, | |||
919 | int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, | 919 | int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, |
920 | char __user *optval, int __user *optlen) | 920 | char __user *optval, int __user *optlen) |
921 | { | 921 | { |
922 | if (level == SOL_UDP || level == SOL_UDPLITE) | 922 | if (IS_SOL_UDPFAMILY(level)) |
923 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); | 923 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); |
924 | return compat_ipv6_getsockopt(sk, level, optname, optval, optlen); | 924 | return compat_ipv6_getsockopt(sk, level, optname, optval, optlen); |
925 | } | 925 | } |