Support SNATing POD traffic to internet at k8s passthrough mode
Change-Id: Icc8d4dd02e4b909cdcd73509945905cbe8f5b0f8
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sRoutingSnatHandler.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sRoutingSnatHandler.java
index 15c184c..1b5b9fd 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sRoutingSnatHandler.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sRoutingSnatHandler.java
@@ -332,7 +332,7 @@
return;
}
- TrafficSelector selector = DefaultTrafficSelector.builder()
+ TrafficSelector ipSelector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchInPort(k8sNode.routerToExtPortNum())
.build();
@@ -344,7 +344,21 @@
k8sFlowRuleService.setRule(
appId,
bridge.deviceId(),
- selector,
+ ipSelector,
+ treatment,
+ PRIORITY_DEFAULT_RULE,
+ ROUTER_ENTRY_TABLE,
+ install);
+
+ TrafficSelector arpSelector = DefaultTrafficSelector.builder()
+ .matchEthType(Ethernet.TYPE_ARP)
+ .matchInPort(k8sNode.routerToExtPortNum())
+ .build();
+
+ k8sFlowRuleService.setRule(
+ appId,
+ bridge.deviceId(),
+ arpSelector,
treatment,
PRIORITY_DEFAULT_RULE,
ROUTER_ENTRY_TABLE,
@@ -358,7 +372,7 @@
return;
}
- TrafficSelector selector = DefaultTrafficSelector.builder()
+ TrafficSelector ipSelector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchInPort(k8sNode.routerPortNum())
.matchIPDst(IpPrefix.valueOf(k8sNode.extBridgeIp(), 32))
@@ -371,7 +385,22 @@
k8sFlowRuleService.setRule(
appId,
bridge.deviceId(),
- selector,
+ ipSelector,
+ treatment,
+ PRIORITY_DEFAULT_RULE,
+ ROUTER_ENTRY_TABLE,
+ install);
+
+ TrafficSelector arpSelector = DefaultTrafficSelector.builder()
+ .matchEthType(Ethernet.TYPE_ARP)
+ .matchInPort(k8sNode.routerPortNum())
+ .matchArpTpa(Ip4Address.valueOf(k8sNode.extBridgeIp().toString()))
+ .build();
+
+ k8sFlowRuleService.setRule(
+ appId,
+ bridge.deviceId(),
+ arpSelector,
treatment,
PRIORITY_DEFAULT_RULE,
ROUTER_ENTRY_TABLE,