diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2006-11-20 15:39:23 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:24:38 -0500 |
commit | 59348b19efebfd6a8d0791ff81d207b16594c94b (patch) | |
tree | a9212a7bf62bd594cf02d23b9e33eb45a46d414d /net/dccp/ipv4.c | |
parent | b1308dc015eb09cf094ca169296738a13ae049ad (diff) |
[DCCP]: Simplified conditions due to use of enum:8 states
This reaps the benefit of the earlier patch, which changed the type of
CCID 3 states to use enums, in that many conditions are now simplified
and the number of possible (unexpected) values is greatly reduced.
In a few instances, this also allowed to simplify pre-conditions; where
care has been taken to retain logical equivalence.
[DCCP]: Introduce a consistent BUG/WARN message scheme
This refines the existing set of DCCP messages so that
* BUG(), BUG_ON(), WARN_ON() have meaningful DCCP-specific counterparts
* DCCP_CRIT (for severe warnings) is not rate-limited
* DCCP_WARN() is introduced as rate-limited wrapper
Using these allows a faster and cleaner transition to their original
counterparts once the code has matured into a full DCCP implementation.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp/ipv4.c')
-rw-r--r-- | net/dccp/ipv4.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 7114befe7d50..ff81679c9f17 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -747,7 +747,7 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
747 | 747 | ||
748 | /* If the packet is shorter than 12 bytes, drop packet and return */ | 748 | /* If the packet is shorter than 12 bytes, drop packet and return */ |
749 | if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) { | 749 | if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) { |
750 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: pskb_may_pull failed\n"); | 750 | DCCP_WARN("pskb_may_pull failed\n"); |
751 | return 1; | 751 | return 1; |
752 | } | 752 | } |
753 | 753 | ||
@@ -755,7 +755,7 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
755 | 755 | ||
756 | /* If P.type is not understood, drop packet and return */ | 756 | /* If P.type is not understood, drop packet and return */ |
757 | if (dh->dccph_type >= DCCP_PKT_INVALID) { | 757 | if (dh->dccph_type >= DCCP_PKT_INVALID) { |
758 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: invalid packet type\n"); | 758 | DCCP_WARN("invalid packet type\n"); |
759 | return 1; | 759 | return 1; |
760 | } | 760 | } |
761 | 761 | ||
@@ -763,16 +763,14 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
763 | * If P.Data Offset is too small for packet type, drop packet and return | 763 | * If P.Data Offset is too small for packet type, drop packet and return |
764 | */ | 764 | */ |
765 | if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { | 765 | if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { |
766 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.Data Offset(%u) " | 766 | DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff); |
767 | "too small\n", dh->dccph_doff); | ||
768 | return 1; | 767 | return 1; |
769 | } | 768 | } |
770 | /* | 769 | /* |
771 | * If P.Data Offset is too too large for packet, drop packet and return | 770 | * If P.Data Offset is too too large for packet, drop packet and return |
772 | */ | 771 | */ |
773 | if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { | 772 | if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { |
774 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.Data Offset(%u) " | 773 | DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff); |
775 | "too large\n", dh->dccph_doff); | ||
776 | return 1; | 774 | return 1; |
777 | } | 775 | } |
778 | 776 | ||
@@ -782,9 +780,8 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
782 | */ | 780 | */ |
783 | if (dh->dccph_type >= DCCP_PKT_DATA && | 781 | if (dh->dccph_type >= DCCP_PKT_DATA && |
784 | dh->dccph_type <= DCCP_PKT_DATAACK && dh->dccph_x == 0) { | 782 | dh->dccph_type <= DCCP_PKT_DATAACK && dh->dccph_x == 0) { |
785 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.type (%s) not Data||Ack||" | 783 | DCCP_WARN("P.type (%s) not Data || [Data]Ack, while P.X == 0\n", |
786 | "DataAck, while P.X == 0\n", | 784 | dccp_packet_name(dh->dccph_type)); |
787 | dccp_packet_name(dh->dccph_type)); | ||
788 | return 1; | 785 | return 1; |
789 | } | 786 | } |
790 | 787 | ||
@@ -794,9 +791,8 @@ int dccp_invalid_packet(struct sk_buff *skb) | |||
794 | */ | 791 | */ |
795 | cscov = dccp_csum_coverage(skb); | 792 | cscov = dccp_csum_coverage(skb); |
796 | if (cscov > skb->len) { | 793 | if (cscov > skb->len) { |
797 | LIMIT_NETDEBUG(KERN_WARNING | 794 | DCCP_WARN("P.CsCov %u exceeds packet length %d\n", |
798 | "DCCP: P.CsCov %u exceeds packet length %d\n", | 795 | dh->dccph_cscov, skb->len); |
799 | dh->dccph_cscov, skb->len); | ||
800 | return 1; | 796 | return 1; |
801 | } | 797 | } |
802 | 798 | ||
@@ -823,9 +819,7 @@ static int dccp_v4_rcv(struct sk_buff *skb) | |||
823 | 819 | ||
824 | /* Step 1: If header checksum is incorrect, drop packet and return */ | 820 | /* Step 1: If header checksum is incorrect, drop packet and return */ |
825 | if (dccp_v4_csum_finish(skb, skb->nh.iph->saddr, skb->nh.iph->daddr)) { | 821 | if (dccp_v4_csum_finish(skb, skb->nh.iph->saddr, skb->nh.iph->daddr)) { |
826 | LIMIT_NETDEBUG(KERN_WARNING | 822 | DCCP_WARN("dropped packet with invalid checksum\n"); |
827 | "%s: dropped packet with invalid checksum\n", | ||
828 | __FUNCTION__); | ||
829 | goto discard_it; | 823 | goto discard_it; |
830 | } | 824 | } |
831 | 825 | ||