I don't support match_tuple method intentionally. I don't think that it's a good idea to convert nxm to OFPMatch.
- >From 2408b6a38695e21586ce48fea560508e58c329b0 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori <[email protected]> Date: Sat, 9 Jun 2012 22:52:43 +0900 Subject: [PATCH] nxm: add vlan support Signed-off-by: FUJITA Tomonori <[email protected]> --- ryu/ofproto/nx_match.py | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py index a9562a5..8af6b2b 100644 --- a/ryu/ofproto/nx_match.py +++ b/ryu/ofproto/nx_match.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation. # Copyright (C) 2011, 2012 Isaku Yamahata <yamahata at valinux co jp> # Copyright (C) 2012 Simon Horman <horms ad verge net au> # @@ -28,6 +28,7 @@ LOG = logging.getLogger('ryu.ofproto.nx_match') UINT64_MAX = (1 << 64) - 1 +UINT16_MAX = (1 << 16) - 1 FWW_IN_PORT = 1 << 0 FWW_DL_SRC = 1 << 2 @@ -64,11 +65,13 @@ class Flow(object): self.dl_dst = mac.DONTCARE self.dl_type = 0 self.nw_tos = 0 + self.vlan_tci = 0 class FlowWildcards(object): def __init__(self): self.tun_id_mask = 0 + self.vlan_tci_mask = 0 self.wildcards = FWW_ALL def set_dl_dst_mask(self, mask): @@ -138,6 +141,13 @@ class ClsRule(object): self.wc.wildcards &= ~FWW_DL_TYPE self.flow.dl_type = dl_type + def set_dl_tci(self, tci): + self.set_dl_tci_masked(tci, UINT16_MAX) + + def set_dl_tci_masked(self, tci, mask): + self.wc.vlan_tci_mask = mask + self.flow.vlan_tci = tci + def set_nw_dscp(self, nw_dscp): self.wc.wildcards &= ~FWW_NW_DSCP self.flow.nw_tos &= ~IP_DSCP_MASK @@ -302,6 +312,19 @@ class MFEthType(MFField): @_register_make +@_set_nxm_headers([ofproto_v1_0.NXM_OF_VLAN_TCI, + ofproto_v1_0.NXM_OF_VLAN_TCI_W]) +class MFVlan(MFField): + @classmethod + def make(cls): + return cls(MF_PACK_STRING_BE16) + + def put(self, buf, offset, rule): + return self.putm(buf, offset, rule.flow.vlan_tci, + rule.wc.vlan_tci_mask) + + +@_register_make @_set_nxm_headers([ofproto_v1_0.NXM_OF_IP_TOS]) class MFIPDSCP(MFField): @classmethod @@ -349,7 +372,13 @@ def serialize_nxm_match(rule, buf, offset): if not rule.wc.wildcards & FWW_DL_TYPE: offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_ETH_TYPE, rule) - # XXX: 802.1Q + # 802.1Q + if rule.wc.vlan_tci_mask != 0: + if rule.wc.vlan_tci_mask == UINT16_MAX: + header = ofproto_v1_0.NXM_OF_VLAN_TCI + else: + header = ofproto_v1_0.NXM_OF_VLAN_TCI_W + offset += nxm_put(buf, offset, header, rule) # L3 if not rule.wc.wildcards & FWW_NW_DSCP: -- 1.7.4.4 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
