#include "nx-match.h"
+#include <netinet/icmp6.h>
+
#include "classifier.h"
#include "dynamic-string.h"
#include "ofp-util.h"
/* Hash table of 'nxm_fields'. */
static struct hmap all_nxm_fields = HMAP_INITIALIZER(&all_nxm_fields);
-/* Possible masks for NXM_OF_ETH_DST_W. */
-static const uint8_t eth_all_0s[ETH_ADDR_LEN]
- = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-static const uint8_t eth_all_1s[ETH_ADDR_LEN]
- = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-static const uint8_t eth_mcast_1[ETH_ADDR_LEN]
- = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
-static const uint8_t eth_mcast_0[ETH_ADDR_LEN]
- = {0xfe, 0xff, 0xff, 0xff, 0xff, 0xff};
-
static void
nxm_init(void)
{
/* Metadata. */
case NFI_NXM_OF_IN_PORT:
flow->in_port = ntohs(get_unaligned_be16(value));
- if (flow->in_port == OFPP_LOCAL) {
- flow->in_port = ODPP_LOCAL;
- }
return 0;
/* Ethernet header. */
if ((wc->wildcards & (FWW_DL_DST | FWW_ETH_MCAST))
!= (FWW_DL_DST | FWW_ETH_MCAST)) {
return NXM_DUP_TYPE;
- } else if (eth_addr_equals(mask, eth_mcast_1)) {
- wc->wildcards &= ~FWW_ETH_MCAST;
- flow->dl_dst[0] = *(uint8_t *) value & 0x01;
- } else if (eth_addr_equals(mask, eth_mcast_0)) {
- wc->wildcards &= ~FWW_DL_DST;
- memcpy(flow->dl_dst, value, ETH_ADDR_LEN);
- flow->dl_dst[0] &= 0xfe;
- } else if (eth_addr_equals(mask, eth_all_0s)) {
- return 0;
- } else if (eth_addr_equals(mask, eth_all_1s)) {
- wc->wildcards &= ~(FWW_DL_DST | FWW_ETH_MCAST);
- memcpy(flow->dl_dst, value, ETH_ADDR_LEN);
+ } else if (flow_wildcards_is_dl_dst_mask_valid(mask)) {
+ cls_rule_set_dl_dst_masked(rule, value, mask);
return 0;
} else {
return NXM_BAD_MASK;
flow->tp_dst = htons(*(uint8_t *) value);
return 0;
+ /* IPv6 Neighbor Discovery. */
+ case NFI_NXM_NX_ND_TARGET:
+ /* We've already verified that it's an ICMPv6 message. */
+ if ((flow->tp_src != htons(ND_NEIGHBOR_SOLICIT))
+ && (flow->tp_src != htons(ND_NEIGHBOR_ADVERT))) {
+ return NXM_BAD_PREREQ;
+ }
+ memcpy(&flow->nd_target, value, sizeof flow->nd_target);
+ return 0;
+ case NFI_NXM_NX_ND_SLL:
+ /* We've already verified that it's an ICMPv6 message. */
+ if (flow->tp_src != htons(ND_NEIGHBOR_SOLICIT)) {
+ return NXM_BAD_PREREQ;
+ }
+ memcpy(flow->arp_sha, value, ETH_ADDR_LEN);
+ return 0;
+ case NFI_NXM_NX_ND_TLL:
+ /* We've already verified that it's an ICMPv6 message. */
+ if (flow->tp_src != htons(ND_NEIGHBOR_ADVERT)) {
+ return NXM_BAD_PREREQ;
+ }
+ memcpy(flow->arp_tha, value, ETH_ADDR_LEN);
+ return 0;
+
/* ARP header. */
case NFI_NXM_OF_ARP_OP:
if (ntohs(get_unaligned_be16(value)) > 255) {
static void
nxm_put_eth_dst(struct ofpbuf *b,
- uint32_t wc, const uint8_t value[ETH_ADDR_LEN])
+ flow_wildcards_t wc, const uint8_t value[ETH_ADDR_LEN])
{
switch (wc & (FWW_DL_DST | FWW_ETH_MCAST)) {
case FWW_DL_DST | FWW_ETH_MCAST:
break;
- case FWW_DL_DST:
- nxm_put_header(b, NXM_OF_ETH_DST_W);
- ofpbuf_put(b, value, ETH_ADDR_LEN);
- ofpbuf_put(b, eth_mcast_1, ETH_ADDR_LEN);
- break;
- case FWW_ETH_MCAST:
+ default:
nxm_put_header(b, NXM_OF_ETH_DST_W);
ofpbuf_put(b, value, ETH_ADDR_LEN);
- ofpbuf_put(b, eth_mcast_0, ETH_ADDR_LEN);
+ ofpbuf_put(b, flow_wildcards_to_dl_dst_mask(wc), ETH_ADDR_LEN);
break;
case 0:
nxm_put_eth(b, NXM_OF_ETH_DST, value);
/* Metadata. */
if (!(wc & FWW_IN_PORT)) {
uint16_t in_port = flow->in_port;
- if (in_port == ODPP_LOCAL) {
- in_port = OFPP_LOCAL;
- }
nxm_put_16(b, NXM_OF_IN_PORT, htons(in_port));
}
case IPPROTO_ICMPV6:
if (!(wc & FWW_TP_SRC)) {
nxm_put_8(b, NXM_NX_ICMPV6_TYPE, ntohs(flow->tp_src));
+
+ if (flow->tp_src == htons(ND_NEIGHBOR_SOLICIT) ||
+ flow->tp_src == htons(ND_NEIGHBOR_ADVERT)) {
+ if (!(wc & FWW_ND_TARGET)) {
+ nxm_put_ipv6(b, NXM_NX_ND_TARGET, &flow->nd_target,
+ &in6addr_exact);
+ }
+ if (!(wc & FWW_ARP_SHA)
+ && flow->tp_src == htons(ND_NEIGHBOR_SOLICIT)) {
+ nxm_put_eth(b, NXM_NX_ND_SLL, flow->arp_sha);
+ }
+ if (!(wc & FWW_ARP_THA)
+ && flow->tp_src == htons(ND_NEIGHBOR_ADVERT)) {
+ nxm_put_eth(b, NXM_NX_ND_TLL, flow->arp_tha);
+ }
+ }
}
if (!(wc & FWW_TP_DST)) {
nxm_put_8(b, NXM_NX_ICMPV6_CODE, ntohs(flow->tp_dst));
{
switch (src->index) {
case NFI_NXM_OF_IN_PORT:
- return flow->in_port == ODPP_LOCAL ? OFPP_LOCAL : flow->in_port;
+ return flow->in_port;
case NFI_NXM_OF_ETH_DST:
return eth_addr_to_uint64(flow->dl_dst);
#endif
case NFI_NXM_NX_ARP_SHA:
+ case NFI_NXM_NX_ND_SLL:
return eth_addr_to_uint64(flow->arp_sha);
case NFI_NXM_NX_ARP_THA:
+ case NFI_NXM_NX_ND_TLL:
return eth_addr_to_uint64(flow->arp_tha);
case NFI_NXM_NX_TUN_ID_W:
case NFI_NXM_NX_IPV6_SRC_W:
case NFI_NXM_NX_IPV6_DST:
case NFI_NXM_NX_IPV6_DST_W:
+ case NFI_NXM_NX_ND_TARGET:
case N_NXM_FIELDS:
NOT_REACHED();
}
case NFI_NXM_NX_IPV6_DST_W:
case NFI_NXM_NX_ICMPV6_TYPE:
case NFI_NXM_NX_ICMPV6_CODE:
+ case NFI_NXM_NX_ND_TARGET:
+ case NFI_NXM_NX_ND_SLL:
+ case NFI_NXM_NX_ND_TLL:
case N_NXM_FIELDS:
NOT_REACHED();
}