Merge "[qca-nss-sfe] Limit the number of connections for low memory profiles."
diff --git a/sfe_ipv4_gre.c b/sfe_ipv4_gre.c
index ea9a000..7f2db3a 100644
--- a/sfe_ipv4_gre.c
+++ b/sfe_ipv4_gre.c
@@ -21,6 +21,7 @@
#include <net/protocol.h>
#include <linux/etherdevice.h>
#include <linux/lockdep.h>
+#include <net/ip.h>
#include <net/gre.h>
#include <net/pptp.h>
@@ -130,6 +131,29 @@
* TODO: revisit to ensure that pass through traffic is not bypassing firewall for fragmented cases
*/
if (unlikely(sync_on_find) && !passthrough) {
+ /*
+ * if we put IP fragmented packets in slow path and non IP fragmented packet in fastpath,
+ * this causes out of order pptp sequence number being received at pptp_rcv_core(). So we need to
+ * flush the rule for the tunnel which has sequence number to avoid out of order sequence number.
+ */
+ if ((gre_hdr->protocol == GRE_PROTO_PPP) && (ntohs(iph->frag_off) & IP_MF)) {
+ struct sfe_ipv4_connection *c = cm->connection;
+ int ret;
+
+ spin_lock_bh(&si->lock);
+ ret = sfe_ipv4_remove_connection(si, c);
+ spin_unlock_bh(&si->lock);
+
+ if (ret) {
+ sfe_ipv4_flush_connection(si, c, SFE_SYNC_REASON_FLUSH);
+ }
+
+ rcu_read_unlock();
+ sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_GRE_IP_OPTIONS_OR_INITIAL_FRAGMENT);
+ DEBUG_TRACE("%px: sfe: pptp cm flushed\n", cm);
+ return 0;
+ }
+
sfe_ipv4_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
rcu_read_unlock();
sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_GRE_IP_OPTIONS_OR_INITIAL_FRAGMENT);