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/ipv4 | |
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/ipv4')
-rw-r--r-- | net/ipv4/Kconfig | 10 | ||||
-rw-r--r-- | net/ipv4/Makefile | 3 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 7 | ||||
-rw-r--r-- | net/ipv4/proc.c | 5 | ||||
-rw-r--r-- | net/ipv4/udp.c | 24 |
5 files changed, 36 insertions, 13 deletions
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 19880b086e71..efe3832c4ad8 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
@@ -632,5 +632,15 @@ config TCP_MD5SIG | |||
632 | 632 | ||
633 | If unsure, say N. | 633 | If unsure, say N. |
634 | 634 | ||
635 | config IP_UDPLITE | ||
636 | bool "IP: UDP-Lite Protocol (RFC 3828)" | ||
637 | default n | ||
638 | ---help--- | ||
639 | UDP-Lite (RFC 3828) is a UDP-like protocol with variable-length | ||
640 | checksum. Read <file:Documentation/networking/udplite.txt> for | ||
641 | details. | ||
642 | |||
643 | If unsure, say N. | ||
644 | |||
635 | source "net/ipv4/ipvs/Kconfig" | 645 | source "net/ipv4/ipvs/Kconfig" |
636 | 646 | ||
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile index ad40ef3f9ebc..e88cebdf3e30 100644 --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile | |||
@@ -8,7 +8,7 @@ obj-y := route.o inetpeer.o protocol.o \ | |||
8 | inet_timewait_sock.o inet_connection_sock.o \ | 8 | inet_timewait_sock.o inet_connection_sock.o \ |
9 | tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ | 9 | tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ |
10 | tcp_minisocks.o tcp_cong.o \ | 10 | tcp_minisocks.o tcp_cong.o \ |
11 | datagram.o raw.o udp.o udplite.o \ | 11 | datagram.o raw.o udp.o \ |
12 | arp.o icmp.o devinet.o af_inet.o igmp.o \ | 12 | arp.o icmp.o devinet.o af_inet.o igmp.o \ |
13 | fib_frontend.o fib_semantics.o \ | 13 | fib_frontend.o fib_semantics.o \ |
14 | inet_fragment.o | 14 | inet_fragment.o |
@@ -49,6 +49,7 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o | |||
49 | obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o | 49 | obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o |
50 | obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o | 50 | obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o |
51 | obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o | 51 | obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o |
52 | obj-$(CONFIG_IP_UDPLITE) += udplite.o | ||
52 | obj-$(CONFIG_NETLABEL) += cipso_ipv4.o | 53 | obj-$(CONFIG_NETLABEL) += cipso_ipv4.o |
53 | 54 | ||
54 | obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ | 55 | obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 4f539bd48718..67260c0eaaa8 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1317,15 +1317,18 @@ static int __init init_ipv4_mibs(void) | |||
1317 | if (snmp_mib_init((void **)udp_statistics, | 1317 | if (snmp_mib_init((void **)udp_statistics, |
1318 | sizeof(struct udp_mib)) < 0) | 1318 | sizeof(struct udp_mib)) < 0) |
1319 | goto err_udp_mib; | 1319 | goto err_udp_mib; |
1320 | #ifdef CONFIG_IP_UDPLITE | ||
1320 | if (snmp_mib_init((void **)udplite_statistics, | 1321 | if (snmp_mib_init((void **)udplite_statistics, |
1321 | sizeof(struct udp_mib)) < 0) | 1322 | sizeof(struct udp_mib)) < 0) |
1322 | goto err_udplite_mib; | 1323 | goto err_udplite_mib; |
1323 | 1324 | #endif | |
1324 | tcp_mib_init(); | 1325 | tcp_mib_init(); |
1325 | 1326 | ||
1326 | return 0; | 1327 | return 0; |
1327 | 1328 | ||
1329 | #ifdef CONFIG_IP_UDPLITE | ||
1328 | err_udplite_mib: | 1330 | err_udplite_mib: |
1331 | #endif | ||
1329 | snmp_mib_free((void **)udp_statistics); | 1332 | snmp_mib_free((void **)udp_statistics); |
1330 | err_udp_mib: | 1333 | err_udp_mib: |
1331 | snmp_mib_free((void **)tcp_statistics); | 1334 | snmp_mib_free((void **)tcp_statistics); |
@@ -1423,8 +1426,10 @@ static int __init inet_init(void) | |||
1423 | /* Setup UDP memory threshold */ | 1426 | /* Setup UDP memory threshold */ |
1424 | udp_init(); | 1427 | udp_init(); |
1425 | 1428 | ||
1429 | #ifdef CONFIG_IP_UDPLITE | ||
1426 | /* Add UDP-Lite (RFC 3828) */ | 1430 | /* Add UDP-Lite (RFC 3828) */ |
1427 | udplite4_register(); | 1431 | udplite4_register(); |
1432 | #endif | ||
1428 | 1433 | ||
1429 | /* | 1434 | /* |
1430 | * Set the ICMP layer up | 1435 | * Set the ICMP layer up |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index d63474c6b400..d75ddb7fa4b8 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -59,7 +59,9 @@ static int sockstat_seq_show(struct seq_file *seq, void *v) | |||
59 | atomic_read(&tcp_memory_allocated)); | 59 | atomic_read(&tcp_memory_allocated)); |
60 | seq_printf(seq, "UDP: inuse %d mem %d\n", sock_prot_inuse_get(&udp_prot), | 60 | seq_printf(seq, "UDP: inuse %d mem %d\n", sock_prot_inuse_get(&udp_prot), |
61 | atomic_read(&udp_memory_allocated)); | 61 | atomic_read(&udp_memory_allocated)); |
62 | #ifdef CONFIG_IP_UDPLITE | ||
62 | seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse_get(&udplite_prot)); | 63 | seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse_get(&udplite_prot)); |
64 | #endif | ||
63 | seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse_get(&raw_prot)); | 65 | seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse_get(&raw_prot)); |
64 | seq_printf(seq, "FRAG: inuse %d memory %d\n", | 66 | seq_printf(seq, "FRAG: inuse %d memory %d\n", |
65 | ip_frag_nqueues(&init_net), ip_frag_mem(&init_net)); | 67 | 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 | snmp_fold_field((void **)udp_statistics, | 351 | snmp_fold_field((void **)udp_statistics, |
350 | snmp4_udp_list[i].entry)); | 352 | snmp4_udp_list[i].entry)); |
351 | 353 | ||
354 | #ifdef CONFIG_IP_UDPLITE | ||
352 | /* the UDP and UDP-Lite MIBs are the same */ | 355 | /* the UDP and UDP-Lite MIBs are the same */ |
353 | seq_puts(seq, "\nUdpLite:"); | 356 | seq_puts(seq, "\nUdpLite:"); |
354 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 357 | 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 | seq_printf(seq, " %lu", | 362 | seq_printf(seq, " %lu", |
360 | snmp_fold_field((void **)udplite_statistics, | 363 | snmp_fold_field((void **)udplite_statistics, |
361 | snmp4_udp_list[i].entry)); | 364 | snmp4_udp_list[i].entry)); |
362 | 365 | #endif | |
363 | seq_putc(seq, '\n'); | 366 | seq_putc(seq, '\n'); |
364 | return 0; | 367 | return 0; |
365 | } | 368 | } |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 7ea1b67b6de1..acc353aa89eb 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1127,7 +1127,7 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh, | |||
1127 | UDP_SKB_CB(skb)->partial_cov = 0; | 1127 | UDP_SKB_CB(skb)->partial_cov = 0; |
1128 | UDP_SKB_CB(skb)->cscov = skb->len; | 1128 | UDP_SKB_CB(skb)->cscov = skb->len; |
1129 | 1129 | ||
1130 | if (proto == IPPROTO_UDPLITE) { | 1130 | if (IS_PROTO_UDPLITE(proto)) { |
1131 | err = udplite_checksum_init(skb, uh); | 1131 | err = udplite_checksum_init(skb, uh); |
1132 | if (err) | 1132 | if (err) |
1133 | return err; | 1133 | return err; |
@@ -1175,7 +1175,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
1175 | if (ulen > skb->len) | 1175 | if (ulen > skb->len) |
1176 | goto short_packet; | 1176 | goto short_packet; |
1177 | 1177 | ||
1178 | if (proto == IPPROTO_UDP) { | 1178 | if (IS_PROTO_UDPLITE(proto)) { |
1179 | /* UDP validates ulen. */ | 1179 | /* UDP validates ulen. */ |
1180 | if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen)) | 1180 | if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen)) |
1181 | goto short_packet; | 1181 | goto short_packet; |
@@ -1217,7 +1217,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
1217 | if (udp_lib_checksum_complete(skb)) | 1217 | if (udp_lib_checksum_complete(skb)) |
1218 | goto csum_error; | 1218 | goto csum_error; |
1219 | 1219 | ||
1220 | UDP_INC_STATS_BH(UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE); | 1220 | UDP_INC_STATS_BH(UDP_MIB_NOPORTS, IS_PROTO_UDPLITE(proto)); |
1221 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); | 1221 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); |
1222 | 1222 | ||
1223 | /* | 1223 | /* |
@@ -1229,7 +1229,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
1229 | 1229 | ||
1230 | short_packet: | 1230 | short_packet: |
1231 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %u.%u.%u.%u:%u %d/%d to %u.%u.%u.%u:%u\n", | 1231 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %u.%u.%u.%u:%u %d/%d to %u.%u.%u.%u:%u\n", |
1232 | proto == IPPROTO_UDPLITE ? "-Lite" : "", | 1232 | IS_PROTO_UDPLITE(proto) ? "-Lite" : "", |
1233 | NIPQUAD(saddr), | 1233 | NIPQUAD(saddr), |
1234 | ntohs(uh->source), | 1234 | ntohs(uh->source), |
1235 | ulen, | 1235 | ulen, |
@@ -1244,14 +1244,14 @@ csum_error: | |||
1244 | * the network is concerned, anyway) as per 4.1.3.4 (MUST). | 1244 | * the network is concerned, anyway) as per 4.1.3.4 (MUST). |
1245 | */ | 1245 | */ |
1246 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n", | 1246 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n", |
1247 | proto == IPPROTO_UDPLITE ? "-Lite" : "", | 1247 | IS_PROTO_UDPLITE(proto) ? "-Lite" : "", |
1248 | NIPQUAD(saddr), | 1248 | NIPQUAD(saddr), |
1249 | ntohs(uh->source), | 1249 | ntohs(uh->source), |
1250 | NIPQUAD(daddr), | 1250 | NIPQUAD(daddr), |
1251 | ntohs(uh->dest), | 1251 | ntohs(uh->dest), |
1252 | ulen); | 1252 | ulen); |
1253 | drop: | 1253 | drop: |
1254 | UDP_INC_STATS_BH(UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); | 1254 | UDP_INC_STATS_BH(UDP_MIB_INERRORS, IS_PROTO_UDPLITE(proto)); |
1255 | kfree_skb(skb); | 1255 | kfree_skb(skb); |
1256 | return 0; | 1256 | return 0; |
1257 | } | 1257 | } |
@@ -1279,7 +1279,9 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
1279 | struct udp_sock *up = udp_sk(sk); | 1279 | struct udp_sock *up = udp_sk(sk); |
1280 | int val; | 1280 | int val; |
1281 | int err = 0; | 1281 | int err = 0; |
1282 | #ifdef CONFIG_IP_UDPLITE | ||
1282 | int is_udplite = IS_UDPLITE(sk); | 1283 | int is_udplite = IS_UDPLITE(sk); |
1284 | #endif | ||
1283 | 1285 | ||
1284 | if (optlen<sizeof(int)) | 1286 | if (optlen<sizeof(int)) |
1285 | return -EINVAL; | 1287 | return -EINVAL; |
@@ -1315,6 +1317,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
1315 | } | 1317 | } |
1316 | break; | 1318 | break; |
1317 | 1319 | ||
1320 | #ifdef CONFIG_IP_UDPLITE | ||
1318 | /* | 1321 | /* |
1319 | * UDP-Lite's partial checksum coverage (RFC 3828). | 1322 | * UDP-Lite's partial checksum coverage (RFC 3828). |
1320 | */ | 1323 | */ |
@@ -1340,6 +1343,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
1340 | up->pcrlen = val; | 1343 | up->pcrlen = val; |
1341 | up->pcflag |= UDPLITE_RECV_CC; | 1344 | up->pcflag |= UDPLITE_RECV_CC; |
1342 | break; | 1345 | break; |
1346 | #endif | ||
1343 | 1347 | ||
1344 | default: | 1348 | default: |
1345 | err = -ENOPROTOOPT; | 1349 | err = -ENOPROTOOPT; |
@@ -1352,7 +1356,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
1352 | int udp_setsockopt(struct sock *sk, int level, int optname, | 1356 | int udp_setsockopt(struct sock *sk, int level, int optname, |
1353 | char __user *optval, int optlen) | 1357 | char __user *optval, int optlen) |
1354 | { | 1358 | { |
1355 | if (level == SOL_UDP || level == SOL_UDPLITE) | 1359 | if (IS_SOL_UDPFAMILY(level)) |
1356 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, | 1360 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, |
1357 | udp_push_pending_frames); | 1361 | udp_push_pending_frames); |
1358 | return ip_setsockopt(sk, level, optname, optval, optlen); | 1362 | return ip_setsockopt(sk, level, optname, optval, optlen); |
@@ -1362,7 +1366,7 @@ int udp_setsockopt(struct sock *sk, int level, int optname, | |||
1362 | int compat_udp_setsockopt(struct sock *sk, int level, int optname, | 1366 | int compat_udp_setsockopt(struct sock *sk, int level, int optname, |
1363 | char __user *optval, int optlen) | 1367 | char __user *optval, int optlen) |
1364 | { | 1368 | { |
1365 | if (level == SOL_UDP || level == SOL_UDPLITE) | 1369 | if (IS_SOL_UDPFAMILY(level)) |
1366 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, | 1370 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, |
1367 | udp_push_pending_frames); | 1371 | udp_push_pending_frames); |
1368 | return compat_ip_setsockopt(sk, level, optname, optval, optlen); | 1372 | 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 | int udp_getsockopt(struct sock *sk, int level, int optname, | 1420 | int udp_getsockopt(struct sock *sk, int level, int optname, |
1417 | char __user *optval, int __user *optlen) | 1421 | char __user *optval, int __user *optlen) |
1418 | { | 1422 | { |
1419 | if (level == SOL_UDP || level == SOL_UDPLITE) | 1423 | if (IS_SOL_UDPFAMILY(level)) |
1420 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); | 1424 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); |
1421 | return ip_getsockopt(sk, level, optname, optval, optlen); | 1425 | return ip_getsockopt(sk, level, optname, optval, optlen); |
1422 | } | 1426 | } |
@@ -1425,7 +1429,7 @@ int udp_getsockopt(struct sock *sk, int level, int optname, | |||
1425 | int compat_udp_getsockopt(struct sock *sk, int level, int optname, | 1429 | int compat_udp_getsockopt(struct sock *sk, int level, int optname, |
1426 | char __user *optval, int __user *optlen) | 1430 | char __user *optval, int __user *optlen) |
1427 | { | 1431 | { |
1428 | if (level == SOL_UDP || level == SOL_UDPLITE) | 1432 | if (IS_SOL_UDPFAMILY(level)) |
1429 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); | 1433 | return udp_lib_getsockopt(sk, level, optname, optval, optlen); |
1430 | return compat_ip_getsockopt(sk, level, optname, optval, optlen); | 1434 | return compat_ip_getsockopt(sk, level, optname, optval, optlen); |
1431 | } | 1435 | } |