aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 1bbf5510cf3a..b4cad50c18e9 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -867,7 +867,7 @@ try_again:
867 { 867 {
868 sin->sin_family = AF_INET; 868 sin->sin_family = AF_INET;
869 sin->sin_port = skb->h.uh->source; 869 sin->sin_port = skb->h.uh->source;
870 sin->sin_addr.s_addr = skb->nh.iph->saddr; 870 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
871 memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); 871 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
872 } 872 }
873 if (inet->cmsg_flags) 873 if (inet->cmsg_flags)
@@ -990,7 +990,7 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
990 return 0; 990 return 0;
991 991
992 /* Now we can update and verify the packet length... */ 992 /* Now we can update and verify the packet length... */
993 iph = skb->nh.iph; 993 iph = ip_hdr(skb);
994 iphlen = iph->ihl << 2; 994 iphlen = iph->ihl << 2;
995 iph->tot_len = htons(ntohs(iph->tot_len) - len); 995 iph->tot_len = htons(ntohs(iph->tot_len) - len);
996 if (skb->len < iphlen + len) { 996 if (skb->len < iphlen + len) {
@@ -1168,6 +1168,7 @@ static int __udp4_lib_mcast_deliver(struct sk_buff *skb,
1168static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh, 1168static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
1169 int proto) 1169 int proto)
1170{ 1170{
1171 const struct iphdr *iph;
1171 int err; 1172 int err;
1172 1173
1173 UDP_SKB_CB(skb)->partial_cov = 0; 1174 UDP_SKB_CB(skb)->partial_cov = 0;
@@ -1179,16 +1180,16 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
1179 return err; 1180 return err;
1180 } 1181 }
1181 1182
1183 iph = ip_hdr(skb);
1182 if (uh->check == 0) { 1184 if (uh->check == 0) {
1183 skb->ip_summed = CHECKSUM_UNNECESSARY; 1185 skb->ip_summed = CHECKSUM_UNNECESSARY;
1184 } else if (skb->ip_summed == CHECKSUM_COMPLETE) { 1186 } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
1185 if (!csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr, 1187 if (!csum_tcpudp_magic(iph->saddr, iph->daddr, skb->len,
1186 skb->len, proto, skb->csum)) 1188 proto, skb->csum))
1187 skb->ip_summed = CHECKSUM_UNNECESSARY; 1189 skb->ip_summed = CHECKSUM_UNNECESSARY;
1188 } 1190 }
1189 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 1191 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
1190 skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr, 1192 skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
1191 skb->nh.iph->daddr,
1192 skb->len, proto, 0); 1193 skb->len, proto, 0);
1193 /* Probably, we should checksum udp header (it should be in cache 1194 /* Probably, we should checksum udp header (it should be in cache
1194 * in any case) and data in tiny packets (< rx copybreak). 1195 * in any case) and data in tiny packets (< rx copybreak).
@@ -1208,8 +1209,8 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
1208 struct udphdr *uh = skb->h.uh; 1209 struct udphdr *uh = skb->h.uh;
1209 unsigned short ulen; 1210 unsigned short ulen;
1210 struct rtable *rt = (struct rtable*)skb->dst; 1211 struct rtable *rt = (struct rtable*)skb->dst;
1211 __be32 saddr = skb->nh.iph->saddr; 1212 __be32 saddr = ip_hdr(skb)->saddr;
1212 __be32 daddr = skb->nh.iph->daddr; 1213 __be32 daddr = ip_hdr(skb)->daddr;
1213 1214
1214 /* 1215 /*
1215 * Validate the packet. 1216 * Validate the packet.