~ubuntu-branches/ubuntu/wily/openvswitch/wily

« back to all changes in this revision

Viewing changes to datapath/linux/compat/udp.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-08-10 11:35:15 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20150810113515-575vj06oq29emxsn
Tags: 2.4.0~git20150810.97bab95-0ubuntu1
* New upstream snapshot from 2.4 branch:
  - d/*: Align any relevant packaging changes with upstream.
* d/*: wrap-and-sort.
* d/openvswitch-{common,vswitch}.install: Correct install location for
  bash completion files.
* d/tests/openflow.py: Explicitly use ovs-testcontroller as provided
  by 2.4.0 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <linux/version.h>
 
2
 
 
3
#ifndef HAVE_UDP_SET_CSUM
 
4
 
 
5
#include <net/udp.h>
 
6
 
 
7
/* Function to set UDP checksum for an IPv4 UDP packet. This is intended
 
8
 * for the simple case like when setting the checksum for a UDP tunnel.
 
9
 */
 
10
void rpl_udp_set_csum(bool nocheck, struct sk_buff *skb,
 
11
                      __be32 saddr, __be32 daddr, int len)
 
12
{
 
13
        struct udphdr *uh = udp_hdr(skb);
 
14
 
 
15
        if (nocheck)
 
16
                uh->check = 0;
 
17
        else if (skb_is_gso(skb))
 
18
                uh->check = ~udp_v4_check(len, saddr, daddr, 0);
 
19
        else if (skb_dst(skb) && skb_dst(skb)->dev &&
 
20
                 (skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) {
 
21
 
 
22
                BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);
 
23
 
 
24
                skb->ip_summed = CHECKSUM_PARTIAL;
 
25
                skb->csum_start = skb_transport_header(skb) - skb->head;
 
26
                skb->csum_offset = offsetof(struct udphdr, check);
 
27
                uh->check = ~udp_v4_check(len, saddr, daddr, 0);
 
28
        } else {
 
29
                __wsum csum;
 
30
 
 
31
                BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);
 
32
 
 
33
                uh->check = 0;
 
34
                csum = skb_checksum(skb, 0, len, 0);
 
35
                uh->check = udp_v4_check(len, saddr, daddr, csum);
 
36
                if (uh->check == 0)
 
37
                        uh->check = CSUM_MANGLED_0;
 
38
 
 
39
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
40
        }
 
41
}
 
42
EXPORT_SYMBOL_GPL(rpl_udp_set_csum);
 
43
 
 
44
#endif /* Linux version < 3.16 */