From eaac4a70a6b80d3afb46b77aa843bbfa3095fd68 Mon Sep 17 00:00:00 2001 From: zhengjiebing Date: Mon, 27 Nov 2023 15:36:00 +0800 Subject: [PATCH] add vlan id in netif --- 0082-add-vlanid-in-netif.patch | 109 +++++++++++++++++++++++++++++++++ lwip.spec | 6 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 0082-add-vlanid-in-netif.patch diff --git a/0082-add-vlanid-in-netif.patch b/0082-add-vlanid-in-netif.patch new file mode 100644 index 0000000..49bffd3 --- /dev/null +++ b/0082-add-vlanid-in-netif.patch @@ -0,0 +1,109 @@ +diff -Nur lwip-org/src/core/netif.c lwip-vlan/src/core/netif.c +--- lwip-org/src/core/netif.c 2023-11-24 17:38:29.428481010 +0800 ++++ lwip-vlan/src/core/netif.c 2023-11-27 18:35:00.172481010 +0800 +@@ -355,6 +355,11 @@ + netif->input = input; + + NETIF_RESET_HINTS(netif); ++ ++#if GAZELLE_ENABLE ++ netif->vlan_enable=false; ++#endif ++ + #if ENABLE_LOOPBACK + netif->loop_first = NULL; + netif->loop_last = NULL; +@@ -441,6 +446,15 @@ + return netif; + } + ++#if GAZELLE_ENABLE ++void ++netif_set_vlan_tci(struct netif *netif, u16_t vlan_tci) ++{ ++ netif->vlan_enable = true; ++ netif->vlan_tci = vlan_tci; ++} ++#endif ++ + static void + netif_do_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr) + { +diff -Nur lwip-org/src/core/tcp.c lwip-vlan/src/core/tcp.c +--- lwip-org/src/core/tcp.c 2023-11-24 17:38:29.448481010 +0800 ++++ lwip-vlan/src/core/tcp.c 2023-11-27 10:42:33.228481010 +0800 +@@ -987,7 +987,9 @@ + lpcb->tos = pcb->tos; + + #if LWIP_VLAN_PCP ++#if !GAZELLE_ENABLE + lpcb->netif_hints.tci = pcb->netif_hints.tci; ++#endif + #endif /* LWIP_VLAN_PCP */ + #if GAZELLE_TCP_REUSE_IPPORT + lpcb->connect_num = 0; +diff -Nur lwip-org/src/core/tcp_in.c lwip-vlan/src/core/tcp_in.c +--- lwip-org/src/core/tcp_in.c 2023-11-24 17:38:29.448481010 +0800 ++++ lwip-vlan/src/core/tcp_in.c 2023-11-27 10:42:33.228481010 +0800 +@@ -808,7 +808,9 @@ + npcb->listener = pcb; + #endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */ + #if LWIP_VLAN_PCP ++#if !GAZELLE_ENABLE + npcb->netif_hints.tci = pcb->netif_hints.tci; ++#endif + #endif /* LWIP_VLAN_PCP */ + /* inherit socket options */ + npcb->so_options = pcb->so_options & SOF_INHERITED; +diff -Nur lwip-org/src/include/lwip/netif.h lwip-vlan/src/include/lwip/netif.h +--- lwip-org/src/include/lwip/netif.h 2023-11-24 17:38:29.440481010 +0800 ++++ lwip-vlan/src/include/lwip/netif.h 2023-11-27 18:33:07.936481010 +0800 +@@ -45,6 +45,10 @@ + + #include "lwip/ip_addr.h" + ++#if GAZELLE_ENABLE ++#include ++#endif ++ + #include "lwip/def.h" + #include "lwip/pbuf.h" + #include "lwip/stats.h" +@@ -357,6 +361,10 @@ + #if GAZELLE_ENABLE + u64_t rxol_flags; + u64_t txol_flags; ++ bool vlan_enable; ++ /** vlan id is an attribute of NIC. The variable 'netif_hints' is not used because it is assigned by pcb, ++ * while non transport layers without pcb cannot be enabled */ ++ u16_t vlan_tci; + #endif + /** descriptive abbreviation */ + char name[2]; +@@ -484,6 +492,7 @@ + #define netif_get_rxol_flags(netif) ((netif)->rxol_flags) + #define netif_get_txol_flags(netif) ((netif)->txol_flags) + ++void netif_set_vlan_tci(struct netif *netif, u16_t vlan_tci); + void netif_set_rtc_mode(struct netif *netif); + void netif_set_rxol_flags(struct netif *netif, u64_t flags); + void netif_set_txol_flags(struct netif *netif, u64_t flags); +diff -Nur lwip-org/src/netif/ethernet.c lwip-vlan/src/netif/ethernet.c +--- lwip-org/src/netif/ethernet.c 2023-11-24 17:38:29.444481010 +0800 ++++ lwip-vlan/src/netif/ethernet.c 2023-11-27 11:07:48.464481010 +0800 +@@ -283,9 +283,15 @@ + vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type); + #elif LWIP_VLAN_PCP + vlan_prio_vid = -1; ++#if !GAZELLE_ENABLE + if (netif->hints && (netif->hints->tci >= 0)) { + vlan_prio_vid = (u16_t)netif->hints->tci; + } ++#else ++ if (netif->vlan_enable) { ++ vlan_prio_vid = netif->vlan_tci; ++ } ++#endif /* GAZELLE_ENABLE */ + #endif + if (vlan_prio_vid >= 0) { + struct eth_vlan_hdr *vlanhdr; diff --git a/lwip.spec b/lwip.spec index 2673ce0..6931262 100644 --- a/lwip.spec +++ b/lwip.spec @@ -4,7 +4,7 @@ Summary: lwip is a small independent implementation of the TCP/IP protocol suite Name: lwip Version: 2.1.3 -Release: 84 +Release: 85 License: BSD URL: http://savannah.nongnu.org/projects/lwip/ Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip @@ -95,6 +95,7 @@ Patch6004: backport-fix-compiling-ETHARP_SUPPORT_VLAN.patch Patch9078: 0079-enable-vlan-define.patch Patch9079: 0080-enable-ipv6.patch Patch9080: 0081-ip6-hdr.patch +Patch9081: 0082-add-vlanid-in-netif.patch BuildRequires: gcc-c++ dos2unix dpdk-devel @@ -125,6 +126,9 @@ cd %{_builddir}/%{name}-%{version}/src %{_libdir}/liblwip.a %changelog +* Mon Nov 27 2023 zhengjiebing - 2.1.3-84 +- add vlan_id in netif + * Fri Nov 24 2023 zhangxingrong - 2.1.3-84 - modify error date