aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-05-07 19:51:46 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-08 23:47:50 -0400
commitb1036c6a470ccf5f18490a7ce4c99422d3bf77c4 (patch)
tree05ecb3e302e157bf34ca555e3e990696b7af92ca
parent1a91de28831a1bd913e14dacf25763f3672e24a9 (diff)
gre: Call skb_checksum_simple_validate
Use skb_checksum_simple_validate to verify checksum. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/gre_demux.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 250be7421ab3..fbfd829f4049 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -93,28 +93,6 @@ void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
93} 93}
94EXPORT_SYMBOL_GPL(gre_build_header); 94EXPORT_SYMBOL_GPL(gre_build_header);
95 95
96static __sum16 check_checksum(struct sk_buff *skb)
97{
98 __sum16 csum = 0;
99
100 switch (skb->ip_summed) {
101 case CHECKSUM_COMPLETE:
102 csum = csum_fold(skb->csum);
103
104 if (!csum)
105 break;
106 /* Fall through. */
107
108 case CHECKSUM_NONE:
109 skb->csum = 0;
110 csum = __skb_checksum_complete(skb);
111 skb->ip_summed = CHECKSUM_COMPLETE;
112 break;
113 }
114
115 return csum;
116}
117
118static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, 96static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
119 bool *csum_err) 97 bool *csum_err)
120{ 98{
@@ -141,7 +119,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
141 119
142 options = (__be32 *)(greh + 1); 120 options = (__be32 *)(greh + 1);
143 if (greh->flags & GRE_CSUM) { 121 if (greh->flags & GRE_CSUM) {
144 if (check_checksum(skb)) { 122 if (skb_checksum_simple_validate(skb)) {
145 *csum_err = true; 123 *csum_err = true;
146 return -EINVAL; 124 return -EINVAL;
147 } 125 }