X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fmeta-flow.c;h=b3a4bffa68a8c94bdf916329748f8a22644506e5;hb=ff0b06eef1d7044df8220ccbed718a6fae55fc10;hp=84ba88bf714d6e5d7ab4843d7fa8845c5eb7ab06;hpb=1b35df45f206a4649c17ca25bc5a3cc12a435052;p=sliver-openvswitch.git diff --git a/lib/meta-flow.c b/lib/meta-flow.c index 84ba88bf7..b3a4bffa6 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012 Nicira Networks. + * Copyright (c) 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,6 +54,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_NONE, true, NXM_NX_TUN_ID, "NXM_NX_TUN_ID", + 0, NULL, }, { MFF_IN_PORT, "in_port", NULL, MF_FIELD_SIZES(be16), @@ -62,6 +63,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_NONE, false, NXM_OF_IN_PORT, "NXM_OF_IN_PORT", + OXM_OF_IN_PORT, "OXM_OF_IN_PORT", }, #define REGISTER(IDX) \ @@ -73,7 +75,8 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_NONE, \ true, \ NXM_NX_REG(IDX), \ - "NXM_NX_REG" #IDX \ + "NXM_NX_REG" #IDX, \ + 0, NULL, \ } #if FLOW_N_REGS > 0 REGISTER(0), @@ -110,19 +113,21 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { { MFF_ETH_SRC, "eth_src", "dl_src", MF_FIELD_SIZES(mac), - MFM_NONE, FWW_DL_SRC, + MFM_FULLY, 0, MFS_ETHERNET, MFP_NONE, true, NXM_OF_ETH_SRC, "NXM_OF_ETH_SRC", + OXM_OF_ETH_SRC, "OXM_OF_ETH_SRC", }, { MFF_ETH_DST, "eth_dst", "dl_dst", MF_FIELD_SIZES(mac), - MFM_MCAST, 0, + MFM_FULLY, 0, MFS_ETHERNET, MFP_NONE, true, NXM_OF_ETH_DST, "NXM_OF_ETH_DST", + OXM_OF_ETH_DST, "OXM_OF_ETH_DST", }, { MFF_ETH_TYPE, "eth_type", "dl_type", MF_FIELD_SIZES(be16), @@ -131,6 +136,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_NONE, false, NXM_OF_ETH_TYPE, "NXM_OF_ETH_TYPE", + OXM_OF_ETH_TYPE, "OXM_OF_ETH_TYPE", }, { @@ -141,6 +147,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_NONE, true, NXM_OF_VLAN_TCI, "NXM_OF_VLAN_TCI", + 0, NULL, }, { MFF_VLAN_VID, "dl_vlan", NULL, sizeof(ovs_be16), 12, @@ -148,7 +155,8 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFS_DECIMAL, MFP_NONE, true, - 0, NULL + 0, NULL, + OXM_OF_VLAN_VID, "OXM_OF_VLAN_VID", }, { MFF_VLAN_PCP, "dl_vlan_pcp", NULL, 1, 3, @@ -156,7 +164,8 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFS_DECIMAL, MFP_NONE, true, - 0, NULL + 0, NULL, + OXM_OF_VLAN_PCP, "OXM_OF_VLAN_PCP", }, /* ## -- ## */ @@ -166,37 +175,41 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { { MFF_IPV4_SRC, "ip_src", "nw_src", MF_FIELD_SIZES(be32), - MFM_CIDR, 0, + MFM_FULLY, 0, MFS_IPV4, MFP_IPV4, true, NXM_OF_IP_SRC, "NXM_OF_IP_SRC", + OXM_OF_IPV4_SRC, "OXM_OF_IPV4_SRC", }, { MFF_IPV4_DST, "ip_dst", "nw_dst", MF_FIELD_SIZES(be32), - MFM_CIDR, 0, + MFM_FULLY, 0, MFS_IPV4, MFP_IPV4, true, NXM_OF_IP_DST, "NXM_OF_IP_DST", + OXM_OF_IPV4_DST, "OXM_OF_IPV4_DST", }, { MFF_IPV6_SRC, "ipv6_src", NULL, MF_FIELD_SIZES(ipv6), - MFM_CIDR, 0, + MFM_FULLY, 0, MFS_IPV6, MFP_IPV6, true, NXM_NX_IPV6_SRC, "NXM_NX_IPV6_SRC", + OXM_OF_IPV6_SRC, "OXM_OF_IPV6_SRC", }, { MFF_IPV6_DST, "ipv6_dst", NULL, MF_FIELD_SIZES(ipv6), - MFM_CIDR, 0, + MFM_FULLY, 0, MFS_IPV6, MFP_IPV6, true, NXM_NX_IPV6_DST, "NXM_NX_IPV6_DST", + OXM_OF_IPV6_DST, "OXM_OF_IPV6_DST", }, { MFF_IPV6_LABEL, "ipv6_label", NULL, @@ -206,6 +219,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_IPV6, false, NXM_NX_IPV6_LABEL, "NXM_NX_IPV6_LABEL", + OXM_OF_IPV6_FLABEL, "OXM_OF_IPV6_FLABEL", }, { @@ -216,6 +230,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_IP_ANY, false, NXM_OF_IP_PROTO, "NXM_OF_IP_PROTO", + OXM_OF_IP_PROTO, "OXM_OF_IP_PROTO", }, { MFF_IP_DSCP, "nw_tos", NULL, MF_FIELD_SIZES(u8), @@ -223,7 +238,8 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFS_DECIMAL, MFP_IP_ANY, true, - NXM_OF_IP_TOS, "NXM_OF_IP_TOS" + NXM_OF_IP_TOS, "NXM_OF_IP_TOS", + OXM_OF_IP_DSCP, "OXM_OF_IP_DSCP", }, { MFF_IP_ECN, "nw_ecn", NULL, 1, 2, @@ -232,6 +248,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_IP_ANY, true, NXM_NX_IP_ECN, "NXM_NX_IP_ECN", + OXM_OF_IP_ECN, "OXM_OF_IP_ECN", }, { MFF_IP_TTL, "nw_ttl", NULL, MF_FIELD_SIZES(u8), @@ -239,7 +256,8 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFS_DECIMAL, MFP_IP_ANY, true, - NXM_NX_IP_TTL, "NXM_NX_IP_TTL" + NXM_NX_IP_TTL, "NXM_NX_IP_TTL", + 0, NULL, }, { MFF_IP_FRAG, "ip_frag", NULL, 1, 2, @@ -247,7 +265,8 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFS_FRAG, MFP_IP_ANY, false, - NXM_NX_IP_FRAG, "NXM_NX_IP_FRAG" + NXM_NX_IP_FRAG, "NXM_NX_IP_FRAG", + 0, NULL, }, { @@ -258,22 +277,25 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ARP, false, NXM_OF_ARP_OP, "NXM_OF_ARP_OP", + OXM_OF_ARP_OP, "OXM_OF_ARP_OP", }, { MFF_ARP_SPA, "arp_spa", NULL, MF_FIELD_SIZES(be32), - MFM_CIDR, 0, + MFM_FULLY, 0, MFS_IPV4, MFP_ARP, false, NXM_OF_ARP_SPA, "NXM_OF_ARP_SPA", + OXM_OF_ARP_SPA, "OXM_OF_ARP_SPA", }, { MFF_ARP_TPA, "arp_tpa", NULL, MF_FIELD_SIZES(be32), - MFM_CIDR, 0, + MFM_FULLY, 0, MFS_IPV4, MFP_ARP, false, NXM_OF_ARP_TPA, "NXM_OF_ARP_TPA", + OXM_OF_ARP_TPA, "OXM_OF_ARP_TPA", }, { MFF_ARP_SHA, "arp_sha", NULL, MF_FIELD_SIZES(mac), @@ -282,6 +304,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ARP, false, NXM_NX_ARP_SHA, "NXM_NX_ARP_SHA", + OXM_OF_ARP_SHA, "OXM_OF_ARP_SHA", }, { MFF_ARP_THA, "arp_tha", NULL, MF_FIELD_SIZES(mac), @@ -290,6 +313,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ARP, false, NXM_NX_ARP_THA, "NXM_NX_ARP_THA", + OXM_OF_ARP_THA, "OXM_OF_ARP_THA", }, /* ## -- ## */ @@ -304,6 +328,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_TCP, true, NXM_OF_TCP_SRC, "NXM_OF_TCP_SRC", + OXM_OF_TCP_SRC, "OXM_OF_TCP_SRC", }, { MFF_TCP_DST, "tcp_dst", "tp_dst", MF_FIELD_SIZES(be16), @@ -312,6 +337,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_TCP, true, NXM_OF_TCP_DST, "NXM_OF_TCP_DST", + OXM_OF_TCP_DST, "OXM_OF_TCP_DST", }, { @@ -322,6 +348,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_UDP, true, NXM_OF_UDP_SRC, "NXM_OF_UDP_SRC", + OXM_OF_UDP_SRC, "OXM_OF_UDP_SRC", }, { MFF_UDP_DST, "udp_dst", NULL, MF_FIELD_SIZES(be16), @@ -330,6 +357,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_UDP, true, NXM_OF_UDP_DST, "NXM_OF_UDP_DST", + OXM_OF_UDP_DST, "OXM_OF_UDP_DST", }, { @@ -340,6 +368,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ICMPV4, false, NXM_OF_ICMP_TYPE, "NXM_OF_ICMP_TYPE", + OXM_OF_ICMPV4_TYPE, "OXM_OF_ICMPV4_TYPE", }, { MFF_ICMPV4_CODE, "icmp_code", NULL, MF_FIELD_SIZES(u8), @@ -348,6 +377,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ICMPV4, false, NXM_OF_ICMP_CODE, "NXM_OF_ICMP_CODE", + OXM_OF_ICMPV4_CODE, "OXM_OF_ICMPV4_CODE", }, { @@ -358,6 +388,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ICMPV6, false, NXM_NX_ICMPV6_TYPE, "NXM_NX_ICMPV6_TYPE", + OXM_OF_ICMPV6_TYPE, "OXM_OF_ICMPV6_TYPE", }, { MFF_ICMPV6_CODE, "icmpv6_code", NULL, MF_FIELD_SIZES(u8), @@ -366,6 +397,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ICMPV6, false, NXM_NX_ICMPV6_CODE, "NXM_NX_ICMPV6_CODE", + OXM_OF_ICMPV6_CODE, "OXM_OF_ICMPV6_CODE", }, /* ## ---- ## */ @@ -375,11 +407,12 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { { MFF_ND_TARGET, "nd_target", NULL, MF_FIELD_SIZES(ipv6), - MFM_NONE, FWW_ND_TARGET, + MFM_FULLY, 0, MFS_IPV6, MFP_ND, false, NXM_NX_ND_TARGET, "NXM_NX_ND_TARGET", + OXM_OF_IPV6_ND_TARGET, "OXM_OF_IPV6_ND_TARGET", }, { MFF_ND_SLL, "nd_sll", NULL, MF_FIELD_SIZES(mac), @@ -388,6 +421,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ND_SOLICIT, false, NXM_NX_ND_SLL, "NXM_NX_ND_SLL", + OXM_OF_IPV6_ND_SLL, "OXM_OF_IPV6_ND_SLL", }, { MFF_ND_TLL, "nd_tll", NULL, MF_FIELD_SIZES(mac), @@ -396,6 +430,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = { MFP_ND_ADVERT, false, NXM_NX_ND_TLL, "NXM_NX_ND_TLL", + OXM_OF_IPV6_ND_TLL, "OXM_OF_IPV6_ND_TLL", } }; @@ -406,6 +441,7 @@ struct nxm_field { }; static struct hmap all_nxm_fields = HMAP_INITIALIZER(&all_nxm_fields); +static struct hmap all_oxm_fields = HMAP_INITIALIZER(&all_oxm_fields); /* Rate limit for parse errors. These always indicate a bug in an OpenFlow * controller and so there's not much point in showing a lot of them. */ @@ -441,40 +477,70 @@ mf_from_name(const char *name) } static void -add_nxm_field(uint32_t nxm_header, const struct mf_field *mf) +add_nxm_field(struct hmap *all_fields, uint32_t nxm_header, + const struct mf_field *mf) { struct nxm_field *f; f = xmalloc(sizeof *f); - hmap_insert(&all_nxm_fields, &f->hmap_node, hash_int(nxm_header, 0)); + hmap_insert(all_fields, &f->hmap_node, hash_int(nxm_header, 0)); f->nxm_header = nxm_header; f->mf = mf; } +static struct hmap * +get_all_fields(uint32_t header) +{ + return IS_OXM_HEADER(header) ? &all_oxm_fields : &all_nxm_fields; +} + +static void +nxm_init_add_field(const struct mf_field *mf, uint32_t header) +{ + struct hmap *all_fields = get_all_fields(header); + + if (!header) { + return; + } + add_nxm_field(all_fields, header, mf); + if (mf->maskable == MFM_NONE) { + return; + } + add_nxm_field(all_fields, NXM_MAKE_WILD_HEADER(header), mf); +} + +#ifndef NDEBUG +static void +nxm_init_verify_field(const struct mf_field *mf, uint32_t header) +{ + if (!header) { + return; + } + assert(mf_from_nxm_header(header) == mf); + /* Some OXM fields are not maskable while their NXM + * counterparts are, just skip this check for now */ + if (mf->maskable == MFM_NONE || IS_OXM_HEADER(header)) { + return; + } + assert(mf_from_nxm_header(NXM_MAKE_WILD_HEADER(mf->nxm_header)) == mf); +} +#endif + static void nxm_init(void) { const struct mf_field *mf; for (mf = mf_fields; mf < &mf_fields[MFF_N_IDS]; mf++) { - if (mf->nxm_header) { - add_nxm_field(mf->nxm_header, mf); - if (mf->maskable != MFM_NONE) { - add_nxm_field(NXM_MAKE_WILD_HEADER(mf->nxm_header), mf); - } - } + nxm_init_add_field(mf, mf->nxm_header); + nxm_init_add_field(mf, mf->oxm_header); } #ifndef NDEBUG /* Verify that the header values are unique. */ for (mf = mf_fields; mf < &mf_fields[MFF_N_IDS]; mf++) { - if (mf->nxm_header) { - assert(mf_from_nxm_header(mf->nxm_header) == mf); - if (mf->maskable != MFM_NONE) { - assert(mf_from_nxm_header(NXM_MAKE_WILD_HEADER(mf->nxm_header)) - == mf); - } - } + nxm_init_verify_field(mf, mf->nxm_header); + nxm_init_verify_field(mf, mf->oxm_header); } #endif } @@ -483,13 +549,13 @@ const struct mf_field * mf_from_nxm_header(uint32_t header) { const struct nxm_field *f; + struct hmap *all_fields = get_all_fields(header); - if (hmap_is_empty(&all_nxm_fields)) { + if (hmap_is_empty(all_fields)) { nxm_init(); } - HMAP_FOR_EACH_IN_BUCKET (f, hmap_node, hash_int(header, 0), - &all_nxm_fields) { + HMAP_FOR_EACH_IN_BUCKET (f, hmap_node, hash_int(header, 0), all_fields) { if (f->nxm_header == header) { return f->mf; } @@ -508,7 +574,6 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) { switch (mf->id) { case MFF_IN_PORT: - case MFF_ETH_SRC: case MFF_ETH_TYPE: case MFF_IP_PROTO: case MFF_IP_DSCP: @@ -518,7 +583,6 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) case MFF_ARP_OP: case MFF_ARP_SHA: case MFF_ARP_THA: - case MFF_ND_TARGET: case MFF_ND_SLL: case MFF_ND_TLL: assert(mf->fww_bit != 0); @@ -556,9 +620,10 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) #endif return !wc->reg_masks[mf->id - MFF_REG0]; + case MFF_ETH_SRC: + return eth_addr_is_zero(wc->dl_src_mask); case MFF_ETH_DST: - return ((wc->wildcards & (FWW_ETH_MCAST | FWW_DL_DST)) - == (FWW_ETH_MCAST | FWW_DL_DST)); + return eth_addr_is_zero(wc->dl_dst_mask); case MFF_VLAN_TCI: return !wc->vlan_tci_mask; @@ -577,6 +642,9 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) case MFF_IPV6_DST: return ipv6_mask_is_any(&wc->ipv6_dst_mask); + case MFF_ND_TARGET: + return ipv6_mask_is_any(&wc->nd_target_mask); + case MFF_IP_FRAG: return !(wc->nw_frag_mask & FLOW_NW_FRAG_MASK); @@ -614,7 +682,6 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc, { switch (mf->id) { case MFF_IN_PORT: - case MFF_ETH_SRC: case MFF_ETH_TYPE: case MFF_IP_PROTO: case MFF_IP_DSCP: @@ -624,7 +691,6 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc, case MFF_ARP_OP: case MFF_ARP_SHA: case MFF_ARP_THA: - case MFF_ND_TARGET: case MFF_ND_SLL: case MFF_ND_TLL: assert(mf->fww_bit != 0); @@ -666,8 +732,11 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc, break; case MFF_ETH_DST: - memcpy(mask->mac, flow_wildcards_to_dl_dst_mask(wc->wildcards), - ETH_ADDR_LEN); + memcpy(mask->mac, wc->dl_dst_mask, ETH_ADDR_LEN); + break; + + case MFF_ETH_SRC: + memcpy(mask->mac, wc->dl_src_mask, ETH_ADDR_LEN); break; case MFF_VLAN_TCI: @@ -694,6 +763,10 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc, mask->ipv6 = wc->ipv6_dst_mask; break; + case MFF_ND_TARGET: + mask->ipv6 = wc->nd_target_mask; + break; + case MFF_IP_FRAG: mask->u8 = wc->nw_frag_mask & FLOW_NW_FRAG_MASK; break; @@ -741,14 +814,6 @@ mf_is_mask_valid(const struct mf_field *mf, const union mf_value *mask) case MFM_FULLY: return true; - - case MFM_CIDR: - return (mf->n_bytes == 4 - ? ip_is_cidr(mask->be32) - : ipv6_is_cidr(&mask->ipv6)); - - case MFM_MCAST: - return flow_wildcards_is_dl_dst_mask_valid(mask->mac); } NOT_REACHED(); @@ -1304,7 +1369,7 @@ mf_set_flow_value(const struct mf_field *mf, break; case MFF_ETH_DST: - memcpy(flow->dl_src, value->mac, ETH_ADDR_LEN); + memcpy(flow->dl_dst, value->mac, ETH_ADDR_LEN); break; case MFF_ETH_TYPE: @@ -1417,6 +1482,19 @@ mf_set_flow_value(const struct mf_field *mf, } } +/* Returns true if 'mf' has a zero value in 'flow', false if it is nonzero. + * + * The caller is responsible for ensuring that 'flow' meets 'mf''s + * prerequisites. */ +bool +mf_is_zero(const struct mf_field *mf, const struct flow *flow) +{ + union mf_value value; + + mf_get_value(mf, flow, &value); + return is_all_zeros((const uint8_t *) &value, mf->n_bytes); +} + /* Makes 'rule' wildcard field 'mf'. * * The caller is responsible for ensuring that 'rule' meets 'mf''s @@ -1479,13 +1557,13 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule) #endif case MFF_ETH_SRC: - rule->wc.wildcards |= FWW_DL_SRC; - memset(rule->flow.dl_src, 0, sizeof rule->flow.dl_src); + memset(rule->flow.dl_src, 0, ETH_ADDR_LEN); + memset(rule->wc.dl_src_mask, 0, ETH_ADDR_LEN); break; case MFF_ETH_DST: - rule->wc.wildcards |= FWW_DL_DST | FWW_ETH_MCAST; - memset(rule->flow.dl_dst, 0, sizeof rule->flow.dl_dst); + memset(rule->flow.dl_dst, 0, ETH_ADDR_LEN); + memset(rule->wc.dl_dst_mask, 0, ETH_ADDR_LEN); break; case MFF_ETH_TYPE: @@ -1589,7 +1667,7 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule) break; case MFF_ND_TARGET: - rule->wc.wildcards |= FWW_ND_TARGET; + memset(&rule->wc.nd_target_mask, 0, sizeof rule->wc.nd_target_mask); memset(&rule->flow.nd_target, 0, sizeof rule->flow.nd_target); break; @@ -1625,7 +1703,6 @@ mf_set(const struct mf_field *mf, switch (mf->id) { case MFF_IN_PORT: - case MFF_ETH_SRC: case MFF_ETH_TYPE: case MFF_VLAN_VID: case MFF_VLAN_PCP: @@ -1641,7 +1718,6 @@ mf_set(const struct mf_field *mf, case MFF_ICMPV4_CODE: case MFF_ICMPV6_TYPE: case MFF_ICMPV6_CODE: - case MFF_ND_TARGET: case MFF_ND_SLL: case MFF_ND_TLL: NOT_REACHED(); @@ -1682,9 +1758,11 @@ mf_set(const struct mf_field *mf, break; case MFF_ETH_DST: - if (flow_wildcards_is_dl_dst_mask_valid(mask->mac)) { - cls_rule_set_dl_dst_masked(rule, value->mac, mask->mac); - } + cls_rule_set_dl_dst_masked(rule, value->mac, mask->mac); + break; + + case MFF_ETH_SRC: + cls_rule_set_dl_src_masked(rule, value->mac, mask->mac); break; case MFF_VLAN_TCI: @@ -1707,6 +1785,10 @@ mf_set(const struct mf_field *mf, cls_rule_set_ipv6_dst_masked(rule, &value->ipv6, &mask->ipv6); break; + case MFF_ND_TARGET: + cls_rule_set_nd_target_masked(rule, &value->ipv6, &mask->ipv6); + break; + case MFF_IP_FRAG: cls_rule_set_nw_frag_masked(rule, value->u8, mask->u8); break; @@ -2004,12 +2086,14 @@ mf_from_ipv6_string(const struct mf_field *mf, const char *s, netmask = strtok_r(NULL, "/", &save_ptr); if (netmask) { - int prefix = atoi(netmask); - if (prefix <= 0 || prefix > 128) { - free(str); - return xasprintf("%s: prefix bits not between 1 and 128", s); - } else { - *mask = ipv6_create_mask(prefix); + if (inet_pton(AF_INET6, netmask, mask) != 1) { + int prefix = atoi(netmask); + if (prefix <= 0 || prefix > 128) { + free(str); + return xasprintf("%s: prefix bits not between 1 and 128", s); + } else { + *mask = ipv6_create_mask(prefix); + } } } else { *mask = in6addr_exact; @@ -2217,10 +2301,7 @@ mf_format(const struct mf_field *mf, break; case MFS_ETHERNET: - ds_put_format(s, ETH_ADDR_FMT, ETH_ADDR_ARGS(value->mac)); - if (mask) { - ds_put_format(s, "/"ETH_ADDR_FMT, ETH_ADDR_ARGS(mask->mac)); - } + eth_format_masked(value->mac, mask->mac, s); break; case MFS_IPV4: