Update OMEC user plane for ip fragmentation support

Change-Id: I4272b7a2f2ac3046a04f253932b69e5718a9f2fa
diff --git a/omec/omec-user-plane/Chart.yaml b/omec/omec-user-plane/Chart.yaml
index 0346fb1..04b0b65 100644
--- a/omec/omec-user-plane/Chart.yaml
+++ b/omec/omec-user-plane/Chart.yaml
@@ -17,4 +17,4 @@
 name: omec-user-plane
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.1.0
+version: 0.1.2
diff --git a/omec/omec-user-plane/files/__init__.py b/omec/omec-user-plane/files/__init__.py
index 7e94051..b3c75bf 100644
--- a/omec/omec-user-plane/files/__init__.py
+++ b/omec/omec-user-plane/files/__init__.py
@@ -1,4 +1,3 @@
 #!/usr/bin/env python
 # SPDX-License-Identifier: Apache-2.0
-# Copyright 2020-present Open Networking Foundation
-# Copyright(c) 2019 Intel Corporation
\ No newline at end of file
+# Copyright(c) 2019 Intel Corporation
diff --git a/omec/omec-user-plane/files/route_control.py b/omec/omec-user-plane/files/route_control.py
index 11621d6..1d9a169 100755
--- a/omec/omec-user-plane/files/route_control.py
+++ b/omec/omec-user-plane/files/route_control.py
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 # SPDX-License-Identifier: Apache-2.0
-# Copyright 2020-present Open Networking Foundation
 # Copyright(c) 2019 Intel Corporation
 
 import argparse
@@ -104,7 +103,7 @@
     iprange = item.iprange
     prefix_len = item.prefix_len
     route_module = item.iface + 'Routes'
-    last_module = item.iface + 'FastPO'
+    last_module = item.iface + 'Merge'
     gateway_mac_str = '{:X}'.format(gateway_mac)
     print('Adding route entry {}/{} for {}'.format(iprange, prefix_len,
                                                    route_module))
@@ -222,7 +221,7 @@
     iprange = item.iprange
     prefix_len = item.prefix_len
     route_module = item.iface + 'Routes'
-    last_module = item.iface + 'FastPO'
+    last_module = item.iface + 'Merge'
 
     neighbor_exists = neighborcache.get(item.neighbor_ip)
     if neighbor_exists:
@@ -336,16 +335,13 @@
         del item
         return
 
-    # Fetch prefix_len
-    item.prefix_len = msg['dst_len']
-
     # if mac is 0, send ARP request
     if gateway_mac == 0:
         print('Adding entry {} in arp probe table'.format(item.iface))
         probe_addr(item, ipdb.interfaces[item.iface].address)
 
     else:  # if gateway_mac is set
-        print('Linking module {}Routes with {}FastPO (Dest MAC: {})'.format(
+        print('Linking module {}Routes with {}Merge (Dest MAC: {})'.format(
             item.iface, item.iface, _mac))
 
         link_route_module(bess, gateway_mac, item)
@@ -362,7 +358,7 @@
 
     item = arpcache.get(neighbor_ip)
     if item:
-        print('Linking module {}Routes with {}FastPO (Dest MAC: {})'.format(
+        print('Linking module {}Routes with {}Merge (Dest MAC: {})'.format(
             item.iface, item.iface, gateway_mac))
 
         # Add route entry, and add item in the registered neighbor cache
diff --git a/omec/omec-user-plane/files/spgwu.bess b/omec/omec-user-plane/files/spgwu.bess
index ebb47ef..76e546d 100644
--- a/omec/omec-user-plane/files/spgwu.bess
+++ b/omec/omec-user-plane/files/spgwu.bess
@@ -1,7 +1,6 @@
 # vim: syntax=py
 # -*- mode: python -*-
 # SPDX-License-Identifier: Apache-2.0
-# Copyright 2020-present Open Networking Foundation
 # Copyright(c) 2019 Intel Corporation
 
 # for errnos
@@ -51,6 +50,9 @@
             else:
                 raise
         idx += 1
+        # RTE_MAX_ETHPORTS is 32 and we need 2 for vdevs
+        if idx == 30:
+          break
     return True if dpdk_ports else False
 
 
@@ -93,13 +95,11 @@
         self.bpf = __bess_module__("{}FastBPF".format(name), 'BPF')
         self.bpf.clear()
 
+        # Reassemble IP4 fragments (if needed)
+        defrag = __bess_module__("{}IP4Defrag".format(name), 'IPDefrag', num_flows=max_ip_defrag_flows, numa=0)
         # Default drop when no matches
-        if max_ip_defrag_flows is not None:
-            ipdefrag = __bess_module__("{}Defrag".format(name), 'IPDefrag', num_flows=max_ip_defrag_flows, numa=0)
-            self.fpi -> ipdefrag:1 -> self.bpf:0 -> Sink()
-            ipdefrag:0 -> Sink()
-        else:
-            self.fpi -> self.bpf:0 -> Sink()
+        self.fpi -> defrag:1 -> self.bpf:0 -> Sink()
+        defrag:0 -> Sink()
 
         # Initialize route module
         self.rtr = __bess_module__("{}Routes".format(name), 'IPLookup')
@@ -170,6 +170,12 @@
                 # Direct control traffic from kernel to DPDK
                 spi -> self.fpo
 
+                # Direct fast path traffic to Frag module
+                merge = __bess_module__("{}Merge".format(name), 'Merge')
+                frag = __bess_module__("{}IP4Frag".format(name), 'IPFrag')
+                merge -> frag:1 -> self.fpo
+                frag:0 -> Sink()
+
                 tc = 'slow{}'.format(wid)
                 try:
                     bess.add_tc(tc, policy='round_robin', wid=wid)
@@ -272,7 +278,6 @@
 # Drop unknown packets
 GTPUEncap:0 -> Sink()
 
-
 # ====================================================
 #       Uplink Pipeline
 # ====================================================
@@ -305,7 +310,8 @@
 
 sgiRoutes = ports[sgi_ifname].rtr
 
-s1uFastBPF:GTPUGate -> EtherDecapTrim::GenericDecap(bytes=14) -> GTPUDecap::GtpuDecap(ename="GTPUEncap"):1 \
+s1uFastBPF:GTPUGate \
+    -> EtherDecapTrim::GenericDecap(bytes=14) -> GTPUDecap::GtpuDecap(ename="GTPUEncap"):1 \
     -> SGIEtherAdd::GenericEncap(fields=[
         {'size': 6, 'value': {'value_int': 0x0}},
         {'size': 6, 'value': {'value_int': mac2hex(mac_by_interface(sgi_ifname))}},
@@ -321,7 +327,6 @@
 GTPUEcho:0 -> Sink()
 GTPUDecap:0 -> Sink()
 
-
 # ====================================================
 #       SIM_TEST
 # ====================================================
diff --git a/omec/omec-user-plane/files/utils.py b/omec/omec-user-plane/files/utils.py
index 860a65d..5b060b6 100644
--- a/omec/omec-user-plane/files/utils.py
+++ b/omec/omec-user-plane/files/utils.py
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 # SPDX-License-Identifier: Apache-2.0
-# Copyright 2020-present Open Networking Foundation
 # Copyright(c) 2019 Intel Corporation
 
 import os
@@ -33,7 +32,6 @@
             return proc.info['pid']
     return
 
-
 def get_json_conf(path, dump):
     conf = json.loads(open(path).read())
     if dump:
diff --git a/omec/omec-user-plane/templates/config/_spgwu.json.tpl b/omec/omec-user-plane/templates/config/_spgwu.json.tpl
index ba36cc7..3fec6b1 100644
--- a/omec/omec-user-plane/templates/config/_spgwu.json.tpl
+++ b/omec/omec-user-plane/templates/config/_spgwu.json.tpl
@@ -8,5 +8,6 @@
     "ifname": {{ .Values.config.spgwu.sgi.device | quote }}
   },
   "workers": {{ .Values.config.spgwu.workers }},
-  "max_sessions": {{ .Values.config.spgwu.maxSessions }}
+  "max_sessions": {{ .Values.config.spgwu.maxSessions }},
+  "max_ip_defrag_flows": {{ .Values.config.spgwu.maxIpDefragFlows }}
 }
diff --git a/omec/omec-user-plane/values.yaml b/omec/omec-user-plane/values.yaml
index 66fd9b3..ebed5a2 100644
--- a/omec/omec-user-plane/values.yaml
+++ b/omec/omec-user-plane/values.yaml
@@ -69,6 +69,7 @@
     name: "dp-staging"
     workers: 1
     maxSessions: 50000
+    maxIpDefragFlows: 1000
     # Provide the S1U and SGI networks facing device name and IP address
     s1u:
       device: s1u