aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-02-29 11:06:47 -0500
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-04 01:18:22 -0500
commite898d4db2749c6052072e9bc4448e396cbdeb06a (patch)
tree2b8673d85210a23e67d0817b18f401411e8936f3 /net/ipv4/udp.c
parentc6aefafb7ec620911d46174eed514f9df639e5a4 (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/udp.c')
-rw-r--r--net/ipv4/udp.c24
1 files changed, 14 insertions, 10 deletions
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
1230short_packet: 1230short_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);
1253drop: 1253drop:
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,
1352int udp_setsockopt(struct sock *sk, int level, int optname, 1356int 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,
1362int compat_udp_setsockopt(struct sock *sk, int level, int optname, 1366int 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,
1416int udp_getsockopt(struct sock *sk, int level, int optname, 1420int 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,
1425int compat_udp_getsockopt(struct sock *sk, int level, int optname, 1429int 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}