Re: git: e72c522858cb - main - divert(4): make it compilable and working without INET

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sat, 03 Sep 2022 22:44:26 UTC
On Tue, 30 Aug 2022, Gleb Smirnoff wrote:

> The branch main has been updated by glebius:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=e72c522858cb3fe179b8ec5700cdbf46c45e917e
>
> commit e72c522858cb3fe179b8ec5700cdbf46c45e917e
> Author:     Gleb Smirnoff <glebius@FreeBSD.org>
> AuthorDate: 2022-08-30 22:09:21 +0000
> Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
> CommitDate: 2022-08-30 22:09:21 +0000
>
>    divert(4): make it compilable and working without INET
>
>    Differential revision:  https://reviews.freebsd.org/D36383

Well, almost at least....

- sysctls require INET
- ip_divert_ptr still requires INET or INET6 (raw_ip.c)
- one of the SCTP blocks has a early-ended #ifdef INET which can just be
   fixed easily compared to the two above.


diff --git sys/netinet/ip_divert.c sys/netinet/ip_divert.c
index 2a5a7677cb71..d1270ee72499 100644
--- sys/netinet/ip_divert.c
+++ sys/netinet/ip_divert.c
@@ -117,6 +117,8 @@ __FBSDID("$FreeBSD$");
   * will apply the entire ruleset to the packet).
   */
+#ifdef INET
  static SYSCTL_NODE(_net_inet, OID_AUTO, divert, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
      "divert(4)");
+#endif

  VNET_PCPUSTAT_DEFINE_STATIC(struct divstat, divstat);
@@ -125,6 +127,8 @@ VNET_PCPUSTAT_SYSINIT(divstat);
  VNET_PCPUSTAT_SYSUNINIT(divstat);
  #endif
+#ifdef INET
  SYSCTL_VNET_PCPUSTAT(_net_inet_divert, OID_AUTO, stats, struct divstat,
      divstat, "divert(4) socket statistics");
+#endif
  #define        DIVSTAT_INC(name)       \
      VNET_PCPUSTAT_ADD(struct divstat, divstat, div_ ## name, 1)
@@ -191,5 +195,4 @@ divert_packet(struct mbuf *m, bool incoming)
                 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
         }
-#endif
  #if defined(SCTP) || defined(SCTP_SUPPORT)
         if (m->m_pkthdr.csum_flags & CSUM_SCTP) {
@@ -201,4 +204,5 @@ divert_packet(struct mbuf *m, bool incoming)
         }
  #endif
+#endif /* INET */
  #ifdef INET6
         if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) {
@@ -686,7 +690,9 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
         return (error);
  }
+#ifdef INET
  SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist,
      CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, div_pcblist,
      "S,xinpcb", "List of active divert sockets");
+#endif

  static struct protosw div_protosw = {
@@ -715,5 +721,7 @@ div_modevent(module_t mod, int type, void *unused)
         case MOD_LOAD:
                 domain_add(&divertdomain);
+#if defined(INET6) || defined(INET)
                 ip_divert_ptr = divert_packet;
+#endif
                 break;
         case MOD_QUIESCE:
@@ -747,5 +755,7 @@ div_modevent(module_t mod, int type, void *unused)
                 }
                 DIVERT_UNLOCK();
+#if defined(INET6) || defined(INET)
                 ip_divert_ptr = NULL;
+#endif
                 domain_remove(&divertdomain);
                 break;



-- 
Bjoern A. Zeeb                                                     r15:7