[qca-nss-sfe]: Vlan tag addition support for ESP packets
Change-Id: Ia3623934bff9ffd6dafcf9b2caed7d638f3508a7
Signed-off-by: Pritam Kumar Jha <quic_pritamku@quicinc.com>
diff --git a/sfe_ipv4_esp.c b/sfe_ipv4_esp.c
index f0b4941..0213939 100644
--- a/sfe_ipv4_esp.c
+++ b/sfe_ipv4_esp.c
@@ -29,14 +29,15 @@
#include "sfe_flow_cookie.h"
#include "sfe_ipv4.h"
#include "sfe_ipv4_esp.h"
+#include "sfe_vlan.h"
/*
* sfe_ipv4_recv_esp()
* Handle ESP packet receives and forwarding
*/
int sfe_ipv4_recv_esp(struct sfe_ipv4 *si, struct sk_buff *skb, struct net_device *dev,
- unsigned int len, struct iphdr *iph, unsigned int ihl,
- bool sync_on_find, 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 sfe_ipv4_connection_match *cm;
struct net_device *xmit_dev;
@@ -115,6 +116,16 @@
}
/*
+ * Do we expect an ingress VLAN tag for this flow?
+ */
+ if (unlikely(!sfe_vlan_validate_ingress_tag(skb, cm->ingress_vlan_hdr_cnt, cm->ingress_vlan_hdr, l2_info))) {
+ rcu_read_unlock();
+ sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_INGRESS_VLAN_TAG_MISMATCH);
+ DEBUG_TRACE("VLAN tag mismatch. skb=%px\n", skb);
+ return 0;
+ }
+
+ /*
* Check if skb was cloned. If it was, unshare it.
*/
if (unlikely(skb_cloned(skb))) {
@@ -184,6 +195,16 @@
}
/*
+ * Check if skb has enough headroom to write L2 headers
+ */
+ if (unlikely(skb_headroom(skb) < cm->l2_hdr_size)) {
+ rcu_read_unlock();
+ DEBUG_TRACE("%px: Not enough headroom: %u\n", skb, skb_headroom(skb));
+ sfe_ipv4_exception_stats_inc(si, SFE_IPV4_EXCEPTION_EVENT_NO_HEADROOM);
+ return 0;
+ }
+
+ /*
* need to ensure that TTL is >=2.
*/
ttl = iph->ttl;
@@ -227,6 +248,13 @@
skb->dev = xmit_dev;
/*
+ * Check to see if we need to add VLAN tags
+ */
+ if (unlikely(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_INSERT_EGRESS_VLAN_TAG)) {
+ sfe_vlan_add_tag(skb, cm->egress_vlan_hdr_cnt, cm->egress_vlan_hdr);
+ }
+
+ /*
* write the layer - 2 header.
*/
if (likely(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_WRITE_L2_HDR)) {