X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdpif-netdev.c;h=ff71a4a1d45aa8adff8c881c29b91f829749a968;hb=c0a56d9fe1fdb57220b9c1e2f709ea2db5d6489d;hp=daaa12280f5ac82e7047ed326d9015e9c880854b;hpb=ae412e7dd89489911a32c6723d4109c6d1de3a38;p=openvswitch diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index daaa1228..ff71a4a1 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -47,7 +47,7 @@ #include "util.h" #include "vlog.h" -VLOG_DEFINE_THIS_MODULE(dpif_netdev) +VLOG_DEFINE_THIS_MODULE(dpif_netdev); /* Configuration parameters. */ enum { N_QUEUES = 2 }; /* Number of queues for dpif_recv(). */ @@ -665,16 +665,9 @@ dpif_netdev_validate_actions(const union odp_action *actions, int n_actions, case ODPAT_CONTROLLER: break; - case ODPAT_SET_VLAN_VID: + case ODPAT_SET_DL_TCI: *mutates = true; - if (a->vlan_vid.vlan_vid & htons(~VLAN_VID_MASK)) { - return EINVAL; - } - break; - - case ODPAT_SET_VLAN_PCP: - *mutates = true; - if (a->vlan_pcp.vlan_pcp & ~(VLAN_PCP_MASK >> VLAN_PCP_SHIFT)) { + if (a->dl_tci.tci & htons(VLAN_CFI)) { return EINVAL; } break; @@ -1013,16 +1006,12 @@ dp_netdev_wait(void) } -/* Modify the TCI field of 'packet'. If a VLAN tag is not present, one - * is added with the TCI field set to 'tci'. If a VLAN tag is present, - * then 'mask' bits are cleared before 'tci' is logically OR'd into the - * TCI field. - * - * Note that the function does not ensure that 'tci' does not affect - * bits outside of 'mask'. +/* Modify the TCI field of 'packet'. If a VLAN tag is present, its TCI field + * is replaced by 'tci'. If a VLAN tag is not present, one is added with the + * TCI field set to 'tci'. */ static void -dp_netdev_modify_vlan_tci(struct ofpbuf *packet, uint16_t tci, uint16_t mask) +dp_netdev_set_dl_tci(struct ofpbuf *packet, uint16_t tci) { struct vlan_eth_header *veh; struct eth_header *eh; @@ -1030,17 +1019,15 @@ dp_netdev_modify_vlan_tci(struct ofpbuf *packet, uint16_t tci, uint16_t mask) eh = packet->l2; if (packet->size >= sizeof(struct vlan_eth_header) && eh->eth_type == htons(ETH_TYPE_VLAN)) { - /* Clear 'mask' bits, but maintain other TCI bits. */ veh = packet->l2; - veh->veth_tci &= ~htons(mask); - veh->veth_tci |= htons(tci); + veh->veth_tci = tci; } else { /* Insert new 802.1Q header. */ struct vlan_eth_header tmp; memcpy(tmp.veth_dst, eh->eth_dst, ETH_ADDR_LEN); memcpy(tmp.veth_src, eh->eth_src, ETH_ADDR_LEN); tmp.veth_type = htons(ETH_TYPE_VLAN); - tmp.veth_tci = htons(tci); + tmp.veth_tci = tci; tmp.veth_next_type = eh->eth_type; veh = ofpbuf_push_uninit(packet, VLAN_HEADER_LEN); @@ -1237,15 +1224,8 @@ dp_netdev_execute_actions(struct dp_netdev *dp, key->in_port, a->controller.arg); break; - case ODPAT_SET_VLAN_VID: - dp_netdev_modify_vlan_tci(packet, ntohs(a->vlan_vid.vlan_vid), - VLAN_VID_MASK); - break; - - case ODPAT_SET_VLAN_PCP: - dp_netdev_modify_vlan_tci(packet, - a->vlan_pcp.vlan_pcp << VLAN_PCP_SHIFT, - VLAN_PCP_MASK); + case ODPAT_SET_DL_TCI: + dp_netdev_set_dl_tci(packet, a->dl_tci.tci); break; case ODPAT_STRIP_VLAN: