[OPNFLWPLUG-238] TCP Flag Reads Fail to install if a MAC Address is included in MatchBuilder Created: 14/Aug/14  Updated: 27/Sep/21  Resolved: 14/Aug/14

Status: Resolved
Project: OpenFlowPlugin
Component/s: General
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Brent Salisbury Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: Other


External issue ID: 1547

 Description   

TCP_Flags match won't work when included with a MAC address in the match fields. I mentioned it to Michal P a couple of months ago and he seemed to have a hunch so Im hoping it is an easy fix. I think I remember him mentioning it is a length issue but time is tight w/ code freeze so Im hoping it is a quick fix as openstack/ODL Sec services are blocked on this one. Marking it major from a perspective of the OVSDB plugin project, feel free to adjust Just upping the pestering as I am blocked until resolved.

Adding the Java API to hopefully help with checking it out. TCP_FLAG requires version 2.1+ of OVS for support. The flowmod does work and install if using the OVS client.

Failed Match Java API:
---------------------

// Ethertype match
EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
ethernetType.setEthernetType(ethTypeBuilder.build());
matchBuilder.setEthernetMatch(ethernetType.build());

EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
EthernetDestinationBuilder ethDestinationBuilder1 = new EthernetDestinationBuilder();
ethDestinationBuilder1.setAddress(new MacAddress("01:00:00:01:01:01"));
ethernetMatch1.setEthernetDestination(ethDestinationBuilder1.build());
matchBuilder.setEthernetMatch(ethernetMatch1.build());

// TCP Protocol Match
IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
ipMatch.setIpProtocol((short) 6);
matchBuilder.setIpMatch(ipMatch.build());

// TCP Port Match
PortNumber dstPort = new PortNumber(80);
TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
tcpMatch.setTcpDestinationPort(dstPort);
matchBuilder.setLayer4Match(tcpMatch.build());

TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
tcpFlagMatch.setTcpFlag(0x002);
matchBuilder.setTcpFlagMatch(tcpFlagMatch.build());

TunnelBuilder tunnelBuilder = new TunnelBuilder();
tunnelBuilder.setTunnelId(new BigInteger("1600"));
matchBuilder.setTunnel(tunnelBuilder.build());

return matchBuilder;

MatchBuilder:
------------
[
_tunnel=Tunnel[
_tunnelId=1600,
augmentation=[
]
],
_ethernetMatch=EthernetMatch[
_ethernetDestination=EthernetDestination[
_address=MacAddress[
_value=01: 00: 00: 01: 01: 01
],
augmentation=[
]
],
augmentation=[
]
],
_ipMatch=IpMatch[
_ipProtocol=6,
augmentation=[
]
],
_layer4Match=TcpMatch[
_tcpDestinationPort=PortNumber[
_value=80
],
augmentation=[
]
],
_tcpFlagMatch=TcpFlagMatch[
_tcpFlag=2,
augmentation=[
]
],
augmentation=[
]
]

If I drop the Mac Addr match it works:
-------------------------------------

// Ethertype match
EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
ethernetType.setEthernetType(ethTypeBuilder.build());
matchBuilder.setEthernetMatch(ethernetType.build());

// TCP Protocol Match
IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
ipMatch.setIpProtocol((short) 6);
matchBuilder.setIpMatch(ipMatch.build());

// TCP Port Match
PortNumber dstPort = new PortNumber(80);
TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
tcpMatch.setTcpDestinationPort(dstPort);
matchBuilder.setLayer4Match(tcpMatch.build());

TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
tcpFlagMatch.setTcpFlag(0x002);
matchBuilder.setTcpFlagMatch(tcpFlagMatch.build());

TunnelBuilder tunnelBuilder = new TunnelBuilder();
tunnelBuilder.setTunnelId(new BigInteger("1600"));
matchBuilder.setTunnel(tunnelBuilder.build());

Matchbuilder:
------------

[
_tunnel=Tunnel[
_tunnelId=1600,
augmentation=[
]
],
_ethernetMatch=EthernetMatch[
_ethernetType=EthernetType[
_type=EtherType[
_value=2048
],
augmentation=[
]
],
augmentation=[
]
],
_ipMatch=IpMatch[
_ipProtocol=6,
augmentation=[
]
],
_layer4Match=TcpMatch[
_tcpDestinationPort=PortNumber[
_value=80
],
augmentation=[
]
],
_tcpFlagMatch=TcpFlagMatch[
_tcpFlag=2,
augmentation=[
]
],
augmentation=[
]
]



 Comments   
Comment by Michal Polkorab [ 14/Aug/14 ]

Hi Brent,

by doing matchBuilder.setEthernetMatch(ethernetMatch1.build()); in the "Failed match Java API", you overwrite the first ethernetMatch (matchBuilder.setEthernetMatch(ethernetType.build()) - which means, that there is no ethType match entry prerequisite in your match (as we can also see in the MatchBuilders).

That should lead to OFPET_BAD_MATCH - OFPBMC_BAD_PREREQ error message. That's why the flow is not installed in the first case and is in second case.

Please try running this code:

EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
ethernetMatch.setEthernetType(ethTypeBuilder.build());

EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
ethDestinationBuilder.setAddress(new MacAddress("01:00:00:01:01:01"));
ethernetMatch.setEthernetDestination(ethDestinationBuilder.build());

matchBuilder.setEthernetMatch(ethernetMatch.build());

// TCP Protocol Match
IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
ipMatch.setIpProtocol((short) 6);
matchBuilder.setIpMatch(ipMatch.build());

// TCP Port Match
PortNumber dstPort = new PortNumber(80);
TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
tcpMatch.setTcpDestinationPort(dstPort);
matchBuilder.setLayer4Match(tcpMatch.build());

TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
tcpFlagMatch.setTcpFlag(0x002);
matchBuilder.setTcpFlagMatch(tcpFlagMatch.build());

TunnelBuilder tunnelBuilder = new TunnelBuilder();
tunnelBuilder.setTunnelId(new BigInteger("1600"));
matchBuilder.setTunnel(tunnelBuilder.build());

Comment by Brent Salisbury [ 14/Aug/14 ]

Thanks Michal(s), really appreciate it. Totally worked, no idea why i thought ethernet fields wouldn't need a match builder per element. Thanks!

Generated at Wed Feb 07 20:31:56 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.