Hello Jonathan,
Thank you very much for your reply!
In the meantime I stumbled accross the same points you mentioned.
In our application, we install the intent using
HostToHostIntent.builder().
See code snipplet #1 afterwards.
To "solve" the problem with the same selector for the return path, I
extended the compile-method of HostToHostIntentCompiler.
It swaps the necessary fields of the selector for the return path.
I guess there is a much better / nicer way to do this, but it seems
to work for now ;)
See code snipplet #2 afterwards.
But regardless if I use the original code or the customized one, I
get an "Failed installation" error (and afterwards a "Failed
withdrawal" error) from the IntentManager (see output at the very
end).
The flows seem to be correctly installed in OpenVSwitch (and is
obviously not rejected by OVS), as they show up shortly before they
are removed again (almost instantly):
root@pve01:~#
ovs-ofctl -OOpenFlow13 dump-flows vmbr3
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x1c00009cefeb95, duration=0.001s, table=0,
n_packets=0, n_bytes=0, send_flow_rem
priority=123,tcp,in_port=3,dl_src=9a:4f:7f:6c:12:9d,dl_dst=ee:74:7f:4e:a8:ef,nw_src=10.0.0.10,nw_dst=10.0.0.11,tp_src=43243,tp_dst=80,tcp_flags=0x010
actions=output:2
cookie=0x1c00009cfdff55, duration=0s, table=0, n_packets=0,
n_bytes=0, send_flow_rem
priority=123,tcp,in_port=2,dl_src=ee:74:7f:4e:a8:ef,dl_dst=9a:4f:7f:6c:12:9d,nw_src=10.0.0.11,nw_dst=10.0.0.10,tp_src=80,tp_dst=43243,tcp_flags=0x010
actions=output:3
Does anyone have a clue why the flows are installed but instantly
withdrawn?
Is there a method which checks the successful flow / intent
installation and fails because it does not understand the TCP flags
or something like that?
Many thanks in advance!
Kind regards,
Lukas
Code snipplet #1 - Intent Installation (we extended OpenFlowJ and
ONOS to support TCP flag matching for OVS 2.3.1):
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchIPSrc(IpPrefix.valueOf(ipSrc, 32))
.matchIPDst(IpPrefix.valueOf(ipDst, 32));
selectorBuilder.matchIPProtocol(IPv4.PROTOCOL_TCP)
.matchTcpSrc(tcpSrc)
.matchTcpDst(tcpDst)
.matchTcpFlags((short) 16);
TrafficTreatment treatment =
DefaultTrafficTreatment.emptyTreatment();
Intent intent = HostToHostIntent.builder()
.appId(appId)
.key(generateKey(ethSrc, ethDst, ipSrc, ipDst,
tcpSrc, tcpDst))
.one(srcId)
.two(dstId)
.selector(selectorBuilder.build())
.treatment(treatment)
.build();
intentService.submit(intent);
Code snipplet #2 - Swapping of selector match fields for return path
if (intent.selector() != null) {
TrafficSelector.Builder reversedSelectorBuilder =
DefaultTrafficSelector.builder();
// Swap values (e.g. src with dst and vice versa)
for (Criterion crit :
intent.selector().criteria()) {
switch (crit.type()) {
case ETH_SRC:
reversedSelectorBuilder.matchEthDst(((EthCriterion)
crit).mac());
break;
case ETH_DST:
reversedSelectorBuilder.matchEthSrc(((EthCriterion)
crit).mac());
break;
case IPV4_SRC:
reversedSelectorBuilder.matchIPDst(((IPCriterion) crit).ip());
break;
case IPV4_DST:
reversedSelectorBuilder.matchIPSrc(((IPCriterion) crit).ip());
break;
case TCP_SRC:
reversedSelectorBuilder.matchTcpDst((short)
((TcpPortCriterion) crit).tcpPort());
break;
case TCP_DST:
reversedSelectorBuilder.matchTcpSrc((short)
((TcpPortCriterion) crit).tcpPort());
break;
case UDP_SRC:
reversedSelectorBuilder.matchUdpDst((short)
((UdpPortCriterion) crit).udpPort());
break;
case UDP_DST:
reversedSelectorBuilder.matchUdpSrc((short)
((UdpPortCriterion) crit).udpPort());
break;
default:
reversedSelectorBuilder.add(crit);
break;
}
}
// Create a temporary HostToHostIntent with our
reversed selector
HostToHostIntent reversedIntent =
HostToHostIntent.builder()
.appId(intent.appId())
.one(intent.two())
.two(intent.one())
.selector(reversedSelectorBuilder.build())
.treatment(intent.treatment())
.constraints(intent.constraints())
.priority(intent.priority())
.build();
// Create the first path intent with the original
intent
// Create the second path intent with the reversed
intent
return Arrays.asList(createPathIntent(pathOne,
one, two, intent),
createPathIntent(pathTwo,
two, one, reversedIntent));
} else {
// Original code
return Arrays.asList(createPathIntent(pathOne,
one, two, intent),
createPathIntent(pathTwo,
two, one, intent));
}
"Failed installation" error from IntentManager (a bit formatted ;)
):
2015-06-23
17:37:43,625 | WARN | vice-installer-3 |
IntentManager | 77 -
org.onosproject.onos-core-net - 1.3.0.SNAPSHOT | Failed
installation:
9A:4F:7F:6C:12:9D,
EE:74:7F:4E:A8:EF,
167772170,
167772171,
-22293,
80
HostToHostIntent{
id=0x54,
key=9A:4F:7F:6C:12:9D,EE:74:7F:4E:A8:EF,167772170,167772171,-22293,80,
appId=DefaultApplicationId{
id=30,
name=ch.fhnw.technik.ip6.imvs28.sfw
},
priority=100,
resources=[
9A:4F:7F:6C:12:9D/-1,
EE:74:7F:4E:A8:EF/-1],
selector=DefaultTrafficSelector{
criteria=[
TCP_SRC{tcpPort=43243},
TCP_FLAGS{bitmask=16},
IP_PROTO{protocol=6},
IPV4_DST{ip=10.0.0.11/32},
ETH_TYPE{ethType=800},
TCP_DST{tcpPort=80},
IPV4_SRC{ip=10.0.0.10/32}
]
},
treatment=DefaultTrafficTreatment{
immediate=[], deferred=[], transition=None,
cleared=false, metadata=null
},
constraints=[],
one=9A:4F:7F:6C:12:9D/-1,
two=EE:74:7F:4E:A8:EF/-1
}
on FlowRuleOperations{
stages=[
[
FlowRuleOperation{
rule=DefaultFlowRule{
id=1c00009cefeb95,
deviceId=of:000076645f70a44a,
priority=123,
selector=[
TCP_SRC{tcpPort=43243},
TCP_FLAGS{bitmask=16},
IP_PROTO{protocol=6},
IPV4_DST{ip=10.0.0.11/32},
ETH_TYPE{ethType=800},
TCP_DST{tcpPort=80},
IN_PORT{port=3},
IPV4_SRC{ip=10.0.0.10/32},
ETH_SRC{mac=9A:4F:7F:6C:12:9D},
ETH_DST{mac=EE:74:7F:4E:A8:EF}
],
treatment=[OUTPUT{port=2}],
tableId=0,
created=1435073850612,
payLoad=null
},
type=ADD
},
FlowRuleOperation{
rule=DefaultFlowRule{
id=1c00009cfdff55,
deviceId=of:000076645f70a44a,
priority=123,
selector=[
TCP_FLAGS{bitmask=16},
TCP_SRC{tcpPort=80},
IP_PROTO{protocol=6},
IPV4_DST{ip=10.0.0.10/32},
TCP_DST{tcpPort=43243},
ETH_TYPE{ethType=800},
IN_PORT{port=2},
IPV4_SRC{ip=10.0.0.11/32},
ETH_SRC{mac=EE:74:7F:4E:A8:EF},
ETH_DST{mac=9A:4F:7F:6C:12:9D}
],
treatment=[OUTPUT{port=3}],
tableId=0,
created=1435073850612,
payLoad=null
},
type=ADD
}
]
]
}