datapath: Set the correct bits for OFPAT_SET_NW_TOS action.
[sliver-openvswitch.git] / datapath / actions.c
index 3eea532..0aefb8d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Distributed under the terms of the GNU GPL version 2.
- * Copyright (c) 2007, 2008, 2009 Nicira Networks.
+ * Copyright (c) 2007, 2008, 2009, 2010 Nicira Networks.
  *
  * Significant portions of this file may be copied from parts of the Linux
  * kernel, by Linus Torvalds and others.
@@ -15,6 +15,7 @@
 #include <linux/udp.h>
 #include <linux/in6.h>
 #include <linux/if_vlan.h>
+#include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/checksum.h>
 #include "datapath.h"
@@ -265,10 +266,10 @@ static struct sk_buff *set_nw_tos(struct sk_buff *skb,
                struct iphdr *nh = ip_hdr(skb);
                u8 *f = &nh->tos;
                u8 old = *f;
+               u8 new;
 
-               /* We only set the lower 6 bits. */
-               u8 new = (a->nw_tos & 0x3f) | (nh->tos & 0xc0);
-
+               /* Set the DSCP bits and preserve the ECN bits. */
+               new = (a->nw_tos & ~INET_ECN_MASK) | (nh->tos & INET_ECN_MASK);
                update_csum(&nh->check, skb, htons((uint16_t)old),
                                htons((uint16_t)new), 0);
                *f = new;