On Thu, Apr 24, 2014 at 08:09:18PM +0000, Chenfei Gao wrote: > I am a newbee to open vswitch community. I am interested on hot trending SDN > and OVS implementation. I have a question about wildcarding the match fields. > ? > > If we don't specify some match field (e.g. tcp_src_port), it will wildcard > and matching all flows on this field. However, is it possible to match the > field, tcp_src_port for instance, > > for a range of numbers in one flowmod? I checked openflow specification and > found that there was only mask for eth_addr and ip_addr and no mask for other > fields like tcp_port. > > Does it mean if i want to match tcp_port for a range of numbers, the only way > is to mod several rules?
Like so many questions about OVS, this is answered in the documentation, in this case in ovs-ofctl(8): tp_src=port/mask tp_dst=port/mask Bitwise match on TCP (or UDP or SCTP) source or destination port, respectively. The port and mask are 16-bit numbers writ- ten in decimal or in hexadecimal prefixed by 0x. Each 1-bit in mask requires that the corresponding bit in port must match. Each 0-bit in mask causes the corresponding bit to be ignored. Bitwise matches on transport ports are rarely useful in isola- tion, but a group of them can be used to reduce the number of flows required to match on a range of transport ports. For example, suppose that the goal is to match TCP source ports 1000 to 1999, inclusive. One way is to insert 1000 flows, each of which matches on a single source port. Another way is to look at the binary representations of 1000 and 1999, as follows: 01111101000 11111001111 and then to transform those into a series of bitwise matches that accomplish the same results: 01111101xxx 0111111xxxx 10xxxxxxxxx 110xxxxxxxx 1110xxxxxxx 11110xxxxxx 1111100xxxx which become the following when written in the syntax required by ovs-ofctl: tcp,tp_src=0x03e8/0xfff8 tcp,tp_src=0x03f0/0xfff0 tcp,tp_src=0x0400/0xfe00 tcp,tp_src=0x0600/0xff00 tcp,tp_src=0x0700/0xff80 tcp,tp_src=0x0780/0xffc0 tcp,tp_src=0x07c0/0xfff0 Only Open vSwitch 1.6 and later supports bitwise matching on transport ports. Like the exact-match forms of tp_src and tp_dst described above, the bitwise match forms apply only when dl_type and nw_proto specify TCP or UDP or SCTP. _______________________________________________ discuss mailing list discuss@openvswitch.org http://openvswitch.org/mailman/listinfo/discuss