aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/udp.c19
-rw-r--r--net/ipv6/udp.c14
2 files changed, 19 insertions, 14 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 3465d4ad301b..5e67e3245299 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -471,6 +471,7 @@ static int udp_push_pending_frames(struct sock *sk)
471 struct sk_buff *skb; 471 struct sk_buff *skb;
472 struct udphdr *uh; 472 struct udphdr *uh;
473 int err = 0; 473 int err = 0;
474 int is_udplite = IS_UDPLITE(sk);
474 __wsum csum = 0; 475 __wsum csum = 0;
475 476
476 /* Grab the skbuff where UDP header space exists. */ 477 /* Grab the skbuff where UDP header space exists. */
@@ -486,7 +487,7 @@ static int udp_push_pending_frames(struct sock *sk)
486 uh->len = htons(up->len); 487 uh->len = htons(up->len);
487 uh->check = 0; 488 uh->check = 0;
488 489
489 if (up->pcflag) /* UDP-Lite */ 490 if (is_udplite) /* UDP-Lite */
490 csum = udplite_csum_outgoing(sk, skb); 491 csum = udplite_csum_outgoing(sk, skb);
491 492
492 else if (sk->sk_no_check == UDP_CSUM_NOXMIT) { /* UDP csum disabled */ 493 else if (sk->sk_no_check == UDP_CSUM_NOXMIT) { /* UDP csum disabled */
@@ -514,7 +515,7 @@ out:
514 up->len = 0; 515 up->len = 0;
515 up->pending = 0; 516 up->pending = 0;
516 if (!err) 517 if (!err)
517 UDP_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, up->pcflag); 518 UDP_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, is_udplite);
518 return err; 519 return err;
519} 520}
520 521
@@ -531,7 +532,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
531 __be32 daddr, faddr, saddr; 532 __be32 daddr, faddr, saddr;
532 __be16 dport; 533 __be16 dport;
533 u8 tos; 534 u8 tos;
534 int err, is_udplite = up->pcflag; 535 int err, is_udplite = IS_UDPLITE(sk);
535 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 536 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
536 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *); 537 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
537 538
@@ -942,6 +943,7 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
942{ 943{
943 struct udp_sock *up = udp_sk(sk); 944 struct udp_sock *up = udp_sk(sk);
944 int rc; 945 int rc;
946 int is_udplite = IS_UDPLITE(sk);
945 947
946 /* 948 /*
947 * Charge it to the socket, dropping if the queue is full. 949 * Charge it to the socket, dropping if the queue is full.
@@ -978,7 +980,7 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
978 /* 980 /*
979 * UDP-Lite specific tests, ignored on UDP sockets 981 * UDP-Lite specific tests, ignored on UDP sockets
980 */ 982 */
981 if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { 983 if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
982 984
983 /* 985 /*
984 * MIB statistics other than incrementing the error count are 986 * MIB statistics other than incrementing the error count are
@@ -1019,14 +1021,14 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
1019 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { 1021 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
1020 /* Note that an ENOMEM error is charged twice */ 1022 /* Note that an ENOMEM error is charged twice */
1021 if (rc == -ENOMEM) 1023 if (rc == -ENOMEM)
1022 UDP_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, up->pcflag); 1024 UDP_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite);
1023 goto drop; 1025 goto drop;
1024 } 1026 }
1025 1027
1026 return 0; 1028 return 0;
1027 1029
1028drop: 1030drop:
1029 UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag); 1031 UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
1030 kfree_skb(skb); 1032 kfree_skb(skb);
1031 return -1; 1033 return -1;
1032} 1034}
@@ -1235,6 +1237,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
1235 struct udp_sock *up = udp_sk(sk); 1237 struct udp_sock *up = udp_sk(sk);
1236 int val; 1238 int val;
1237 int err = 0; 1239 int err = 0;
1240 int is_udplite = IS_UDPLITE(sk);
1238 1241
1239 if (optlen<sizeof(int)) 1242 if (optlen<sizeof(int))
1240 return -EINVAL; 1243 return -EINVAL;
@@ -1276,7 +1279,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
1276 /* The sender sets actual checksum coverage length via this option. 1279 /* The sender sets actual checksum coverage length via this option.
1277 * The case coverage > packet length is handled by send module. */ 1280 * The case coverage > packet length is handled by send module. */
1278 case UDPLITE_SEND_CSCOV: 1281 case UDPLITE_SEND_CSCOV:
1279 if (!up->pcflag) /* Disable the option on UDP sockets */ 1282 if (!is_udplite) /* Disable the option on UDP sockets */
1280 return -ENOPROTOOPT; 1283 return -ENOPROTOOPT;
1281 if (val != 0 && val < 8) /* Illegal coverage: use default (8) */ 1284 if (val != 0 && val < 8) /* Illegal coverage: use default (8) */
1282 val = 8; 1285 val = 8;
@@ -1288,7 +1291,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
1288 * sense, this should be set to at least 8 (as done below). If zero is 1291 * sense, this should be set to at least 8 (as done below). If zero is
1289 * used, this again means full checksum coverage. */ 1292 * used, this again means full checksum coverage. */
1290 case UDPLITE_RECV_CSCOV: 1293 case UDPLITE_RECV_CSCOV:
1291 if (!up->pcflag) /* Disable the option on UDP sockets */ 1294 if (!is_udplite) /* Disable the option on UDP sockets */
1292 return -ENOPROTOOPT; 1295 return -ENOPROTOOPT;
1293 if (val != 0 && val < 8) /* Avoid silly minimal values. */ 1296 if (val != 0 && val < 8) /* Avoid silly minimal values. */
1294 val = 8; 1297 val = 8;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index b0474a618bbe..77ab31b99232 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -260,6 +260,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
260{ 260{
261 struct udp_sock *up = udp_sk(sk); 261 struct udp_sock *up = udp_sk(sk);
262 int rc; 262 int rc;
263 int is_udplite = IS_UDPLITE(sk);
263 264
264 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 265 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
265 goto drop; 266 goto drop;
@@ -267,7 +268,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
267 /* 268 /*
268 * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c). 269 * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c).
269 */ 270 */
270 if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { 271 if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
271 272
272 if (up->pcrlen == 0) { /* full coverage was set */ 273 if (up->pcrlen == 0) { /* full coverage was set */
273 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE6: partial coverage" 274 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE6: partial coverage"
@@ -291,13 +292,13 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
291 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { 292 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
292 /* Note that an ENOMEM error is charged twice */ 293 /* Note that an ENOMEM error is charged twice */
293 if (rc == -ENOMEM) 294 if (rc == -ENOMEM)
294 UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, up->pcflag); 295 UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite);
295 goto drop; 296 goto drop;
296 } 297 }
297 298
298 return 0; 299 return 0;
299drop: 300drop:
300 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag); 301 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
301 kfree_skb(skb); 302 kfree_skb(skb);
302 return -1; 303 return -1;
303} 304}
@@ -525,6 +526,7 @@ static int udp_v6_push_pending_frames(struct sock *sk)
525 struct inet_sock *inet = inet_sk(sk); 526 struct inet_sock *inet = inet_sk(sk);
526 struct flowi *fl = &inet->cork.fl; 527 struct flowi *fl = &inet->cork.fl;
527 int err = 0; 528 int err = 0;
529 int is_udplite = IS_UDPLITE(sk);
528 __wsum csum = 0; 530 __wsum csum = 0;
529 531
530 /* Grab the skbuff where UDP header space exists. */ 532 /* Grab the skbuff where UDP header space exists. */
@@ -540,7 +542,7 @@ static int udp_v6_push_pending_frames(struct sock *sk)
540 uh->len = htons(up->len); 542 uh->len = htons(up->len);
541 uh->check = 0; 543 uh->check = 0;
542 544
543 if (up->pcflag) 545 if (is_udplite)
544 csum = udplite_csum_outgoing(sk, skb); 546 csum = udplite_csum_outgoing(sk, skb);
545 else 547 else
546 csum = udp_csum_outgoing(sk, skb); 548 csum = udp_csum_outgoing(sk, skb);
@@ -556,7 +558,7 @@ out:
556 up->len = 0; 558 up->len = 0;
557 up->pending = 0; 559 up->pending = 0;
558 if (!err) 560 if (!err)
559 UDP6_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, up->pcflag); 561 UDP6_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, is_udplite);
560 return err; 562 return err;
561} 563}
562 564
@@ -580,7 +582,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
580 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 582 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
581 int err; 583 int err;
582 int connected = 0; 584 int connected = 0;
583 int is_udplite = up->pcflag; 585 int is_udplite = IS_UDPLITE(sk);
584 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *); 586 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
585 587
586 /* destination address check */ 588 /* destination address check */