From nobody Tue Aug 30 22:49:28 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHMtx07PVz4bVJ7; Tue, 30 Aug 2022 22:49:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHMtw5vwRz3hG6; Tue, 30 Aug 2022 22:49:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661899768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5b0iUD3DwGjR4kfAoccaRm1DD3eQ8k+dwqLTGDFmPC8=; b=MDFK2O3POgh/OzsuoNltmENjJE32LpYv2Oyn1npHh86HSF3Sjr248jwEK/+dL7mW5FLtWX 6HsvJcjHEFM9CalFEyxhNOBzcZ8H+4g4GyxO9ceZVmZyzbORdvVX+EV8TvOZ/BvlXtH2q6 Ly82fuA67xZbjC+9Ny1rdLjheNH4FOFlGcgiUwaRlPmVHfrG3URiSI6g3zmXhfsic+TaTm gK/O/ErzrH/hsHolRlU+/CbUffyFYIdLWxoyfPqea5rIGVkWf9Mqc1jTWso6wY7NCtAJ0x K9Oq/zYLMdmZGI1r1D7nnFD+iixZkEqXT+SmNrb7i3Q01L7Xhk2wPeSMQMrPDg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MHMtw4w4wzw7f; Tue, 30 Aug 2022 22:49:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27UMnSbW022110; Tue, 30 Aug 2022 22:49:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27UMnSwI022109; Tue, 30 Aug 2022 22:49:28 GMT (envelope-from git) Date: Tue, 30 Aug 2022 22:49:28 GMT Message-Id: <202208302249.27UMnSwI022109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: e72c522858cb - main - divert(4): make it compilable and working without INET List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e72c522858cb3fe179b8ec5700cdbf46c45e917e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661899768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5b0iUD3DwGjR4kfAoccaRm1DD3eQ8k+dwqLTGDFmPC8=; b=xAqn1o0BX1Vpmf7h4l3aKp9+VCfO9ep4wnWMa9t9SfvLV/icFdYaiOeqVbTd7LXTvRwC6N rYBxfjpsYj4UVCcnegQo40PFzmPY5yf72XnufryxSctQZIKMrlE1OyTMP7yV55FgodSMB6 MZ2NBFXG2afTXXiKfL97m9FrBYpviQMMYJH5UWR0y1ZatNQYAik9GEaDLUZKXc5QhKEsfc wQygAb5u6WIqzYRDL/bGPzIvcCj6I497e3I9otQF8iMNVdDAjW7ghjRHiIzGG6TUfZ7BVz xms6el9wtwratiEHcOPaavkSMaO9ef1Nx4VsdRXM+7gyO7SNuEtE5llO2Vdp+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661899768; a=rsa-sha256; cv=none; b=M8WBiILSkqGhs//LqRZ/m28A7RC41RzDwiJZQHEGHfGqd9QtsmP5lBSXDL4xMMziHbLRC0 VgjSwzcKpSLPzdUbFYo/nQwVpj432Pm0RlUv0IyVRvZa7xvzmW1/o/gIgpOH90i0I3R2+r s5MwEmrlxNtXrXbAEpgpSkF9chczZWemP2IwIG7yD3GXsm2BeC9UaX6OqEYYU8WD7hM7Fc Xx3ORkimQlgJAMT6QoC89Ka0DI0iuC8O5ik6NblL1zh7xkqwjIfA3iCcKkCSK/m4dR86/5 k+qwxrM5P9LelbELPABTJo48d5zdVFkaOuaCaguMhvko4CVsaGCC07YKN1UtPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=e72c522858cb3fe179b8ec5700cdbf46c45e917e commit e72c522858cb3fe179b8ec5700cdbf46c45e917e Author: Gleb Smirnoff AuthorDate: 2022-08-30 22:09:21 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-30 22:09:21 +0000 divert(4): make it compilable and working without INET Differential revision: https://reviews.freebsd.org/D36383 --- sys/conf/files | 2 +- sys/netinet/ip_divert.c | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index f9bd87f20894..1e3518fcfcb0 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4333,7 +4333,7 @@ netinet/in_prot.c optional inet | inet6 netinet/in_proto.c optional inet | inet6 netinet/in_rmx.c optional inet netinet/in_rss.c optional inet rss -netinet/ip_divert.c optional inet ipdivert ipfirewall +netinet/ip_divert.c optional ipdivert ipfirewall netinet/ip_ecn.c optional inet | inet6 netinet/ip_encap.c optional inet | inet6 netinet/ip_fastfwd.c optional inet diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 7e0a09bd8e3a..2a5a7677cb71 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -35,9 +35,6 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" #include "opt_sctp.h" -#ifndef INET -#error "IPDIVERT requires INET" /* XXX! */ -#endif #include #include @@ -171,9 +168,6 @@ MTX_SYSINIT(divert, &divert_mtx, "divert(4) socket pcb lists", MTX_DEF); static void divert_packet(struct mbuf *m, bool incoming) { -#if defined(SCTP) || defined(SCTP_SUPPORT) - struct ip *ip; -#endif struct divcb *dcb; u_int16_t nport; struct sockaddr_in divsrc; @@ -190,14 +184,17 @@ divert_packet(struct mbuf *m, bool incoming) if (m->m_len < sizeof(struct ip) && (m = m_pullup(m, sizeof(struct ip))) == NULL) return; - +#ifdef INET /* Delayed checksums are currently not compatible with divert. */ if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } +#endif #if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP) { + struct ip *ip; + ip = mtod(m, struct ip *); sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); m->m_pkthdr.csum_flags &= ~CSUM_SCTP; @@ -379,9 +376,11 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, ip = mtod(m, struct ip *); switch (ip->ip_v) { +#ifdef INET case IPVERSION: family = AF_INET; break; +#endif #ifdef INET6 case IPV6_VERSION >> 4: family = AF_INET6; @@ -414,17 +413,22 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, static int div_output_outbound(int family, struct socket *so, struct mbuf *m) { - struct ip *const ip = mtod(m, struct ip *); int error; switch (family) { +#ifdef INET case AF_INET: + { + struct ip *const ip = mtod(m, struct ip *); + /* Don't allow packet length sizes that will crash. */ if (((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) { m_freem(m); return (EINVAL); } break; + } +#endif #ifdef INET6 case AF_INET6: { @@ -446,11 +450,13 @@ div_output_outbound(int family, struct socket *so, struct mbuf *m) error = 0; switch (family) { +#ifdef INET case AF_INET: error = ip_output(m, NULL, NULL, ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0) | IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL); break; +#endif #ifdef INET6 case AF_INET6: error = ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL); @@ -472,7 +478,6 @@ static int div_output_inbound(int family, struct socket *so, struct mbuf *m, struct sockaddr_in *sin) { - const struct ip *ip; struct ifaddr *ifa; if (m->m_pkthdr.rcvif == NULL) { @@ -497,7 +502,11 @@ div_output_inbound(int family, struct socket *so, struct mbuf *m, #endif /* Send packet to input processing via netisr */ switch (family) { +#ifdef INET case AF_INET: + { + const struct ip *ip; + ip = mtod(m, struct ip *); /* * Restore M_BCAST flag when destination address is @@ -510,6 +519,8 @@ div_output_inbound(int family, struct socket *so, struct mbuf *m, netisr_queue_src(NETISR_IP, (uintptr_t)so, m); DIVSTAT_INC(inbound); break; + } +#endif #ifdef INET6 case AF_INET6: netisr_queue_src(NETISR_IPV6, (uintptr_t)so, m);