X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdpif-netdev.c;h=bc93a10244ef6216c1b497f0cbd318ddd2a5398e;hb=20d035b27559fe3823a09d72293c81281d3516c4;hp=b4e788ff1ca35fb2932c547b2b7838ce64d158ac;hpb=abff858b5ad310a529d5a5ac2a230ee4ac9736db;p=openvswitch diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index b4e788ff..bc93a102 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1086,12 +1086,19 @@ dp_netdev_set_ip_tos(struct ip_header *nh, uint8_t new_tos) { uint8_t *field = &nh->ip_tos; - /* Set the DSCP bits and preserve the ECN bits. */ - uint8_t new = new_tos | (nh->ip_tos & IP_ECN_MASK); - nh->ip_csum = recalc_csum16(nh->ip_csum, htons((uint16_t)*field), - htons((uint16_t) new)); - *field = new; + htons((uint16_t) new_tos)); + *field = new_tos; +} + +static void +dp_netdev_set_ip_ttl(struct ip_header *nh, uint8_t new_ttl) +{ + uint8_t *field = &nh->ip_ttl; + + nh->ip_csum = recalc_csum16(nh->ip_csum, htons(*field << 8), + htons(new_ttl << 8)); + *field = new_ttl; } static void @@ -1108,6 +1115,9 @@ dp_netdev_set_ipv4(struct ofpbuf *packet, const struct ovs_key_ipv4 *ipv4_key) if (nh->ip_tos != ipv4_key->ipv4_tos) { dp_netdev_set_ip_tos(nh, ipv4_key->ipv4_tos); } + if (nh->ip_ttl != ipv4_key->ipv4_ttl) { + dp_netdev_set_ip_ttl(nh, ipv4_key->ipv4_ttl); + } } static void @@ -1264,10 +1274,11 @@ execute_set_action(struct ofpbuf *packet, const struct nlattr *a) break; case OVS_KEY_ATTR_UNSPEC: + case OVS_KEY_ATTR_ENCAP: case OVS_KEY_ATTR_ETHERTYPE: case OVS_KEY_ATTR_IPV6: case OVS_KEY_ATTR_IN_PORT: - case OVS_KEY_ATTR_8021Q: + case OVS_KEY_ATTR_VLAN: case OVS_KEY_ATTR_ICMP: case OVS_KEY_ATTR_ICMPV6: case OVS_KEY_ATTR_ARP: @@ -1288,8 +1299,7 @@ dp_netdev_execute_actions(struct dp_netdev *dp, unsigned int left; NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) { - const struct nlattr *nested; - const struct ovs_key_8021q *q_key; + const struct ovs_action_push_vlan *vlan; int type = nl_attr_type(a); switch ((enum ovs_action_attr) type) { @@ -1301,15 +1311,12 @@ dp_netdev_execute_actions(struct dp_netdev *dp, dp_netdev_action_userspace(dp, packet, key, a); break; - case OVS_ACTION_ATTR_PUSH: - nested = nl_attr_get(a); - assert(nl_attr_type(nested) == OVS_KEY_ATTR_8021Q); - q_key = nl_attr_get_unspec(nested, sizeof(*q_key)); - eth_push_vlan(packet, q_key->q_tci); + case OVS_ACTION_ATTR_PUSH_VLAN: + vlan = nl_attr_get(a); + eth_push_vlan(packet, vlan->vlan_tci & ~htons(VLAN_CFI)); break; - case OVS_ACTION_ATTR_POP: - assert(nl_attr_get_u16(a) == OVS_KEY_ATTR_8021Q); + case OVS_ACTION_ATTR_POP_VLAN: dp_netdev_pop_vlan(packet); break;