[qca-nss-sfe] change flush to sync status in some cases
Exception the packets to the network stack after sync'ing the stats.
SFE exceptions packets, if TTL < 2, the size of the packet is greater
than the transmit device, there are IP options or the packet
is fragmented
Change-Id: If2a214a7749c4a52814d272962d8ab3f9e673322
Signed-off-by: Ken Zhu <quic_guigenz@quicinc.com>
diff --git a/sfe_ipv4_udp.c b/sfe_ipv4_udp.c
index 30aba15..44164e2 100644
--- a/sfe_ipv4_udp.c
+++ b/sfe_ipv4_udp.c
@@ -116,8 +116,8 @@
* Handle UDP packet receives and forwarding.
*/
int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct net_device *dev,
- unsigned int len, struct iphdr *iph, unsigned int ihl, bool flush_on_find,
- struct sfe_l2_info *l2_info, bool tun_outer)
+ unsigned int len, struct iphdr *iph, unsigned int ihl,
+ bool sync_on_find, struct sfe_l2_info *l2_info, bool tun_outer)
{
struct udphdr *udph;
__be32 src_ip;
@@ -128,7 +128,6 @@
u8 ttl;
struct net_device *xmit_dev;
bool hw_csum;
- bool ret;
int err;
bool bridge_flow;
@@ -184,22 +183,15 @@
}
/*
- * If our packet has beern marked as "flush on find" we can't actually
+ * If our packet has beern marked as "sync on find" we can't actually
* forward it in the fast path, but now that we've found an associated
- * connection we can flush that out before we process the packet.
+ * connection we need sync its status before exception it to slow path.
*/
- if (unlikely(flush_on_find)) {
- struct sfe_ipv4_connection *c = cm->connection;
- 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);
- }
+ if (unlikely(sync_on_find)) {
+ sfe_ipv4_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
rcu_read_unlock();
sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_UDP_IP_OPTIONS_OR_INITIAL_FRAGMENT);
- DEBUG_TRACE("%px: sfe: flush on find\n", cm);
+ DEBUG_TRACE("%px: sfe: sync on find\n", cm);
return 0;
}
@@ -223,17 +215,10 @@
if (likely(!bridge_flow)) {
ttl = iph->ttl;
if (unlikely(ttl < 2)) {
- struct sfe_ipv4_connection *c = cm->connection;
- 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);
- }
+ sfe_ipv4_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
rcu_read_unlock();
- DEBUG_TRACE("TTL too low\n");
+ DEBUG_TRACE("%px: sfe: TTL too low\n", skb);
sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_UDP_SMALL_TTL);
return 0;
}
@@ -244,17 +229,10 @@
* we can't forward it easily.
*/
if (unlikely(len > cm->xmit_dev_mtu)) {
- struct sfe_ipv4_connection *c = cm->connection;
- spin_lock_bh(&si->lock);
- ret = sfe_ipv4_remove_connection(si, c);
- spin_unlock_bh(&si->lock);
-
- DEBUG_TRACE("%px: larger than mtu\n", cm);
- if (ret) {
- sfe_ipv4_flush_connection(si, c, SFE_SYNC_REASON_FLUSH);
- }
+ sfe_ipv4_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
rcu_read_unlock();
sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_UDP_NEEDS_FRAGMENTATION);
+ DEBUG_TRACE("%px: sfe: larger than MTU\n", cm);
return 0;
}