From nobody Thu Dec 19 15:39:37 2024 X-Original-To: dev-commits-src-main@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 4YDZVK57plz5hMZH; Thu, 19 Dec 2024 15:39:37 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YDZVK4Pr5z4l5N; Thu, 19 Dec 2024 15:39:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734622777; 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=sHWJ6lf3FbLHj5XasYG/lgnreLkrbWQC90zX11HXZps=; b=KmrxhoTntN8PYI613tCrHI8GlsIYnjZWzUUdzrhcaLpEp03NmiaZJLaY4u3uedQ6E2/nJh DjmUZajpBUalQ1zu+LA2iiayItDZH3yVuO7CMUQzgGD3cdcbw3HhMc1OzP9NbLWSbrBzAd +mPMpetvcLuaCNJi0X1glSpWtvrAiwaoE25OooJcPxdJNHReJ//CT7w8c/V19hDxaz6sfS Zncb9OLJwTYoW/HgTZ9uGcIJfAGQLOjnKXCA1xA3P87eHi+jFfpkQuvqWuaJp74SyXGeGy S8OyNqZAPfPEJeO/12NzSXpSYG02e3wHtdANZA0XA0/cLMYZejbdLyvAd5ZPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734622777; 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=sHWJ6lf3FbLHj5XasYG/lgnreLkrbWQC90zX11HXZps=; b=pTs1Ifn0eE0CQa9jmxaMD+5h4hUFOpsp8DKKSqBzGtThl3iu9HyfI2rWiuyChu5wx8+i+i 3/UtWv35aFrRLJE4TmTSMnk4PlUChRD/iLOAywdQEkkREw01ddkHesAmSfYW/BCNVVvi45 gK5SUPT+H9Xwcu6dsErBOB1KKMxrrvdRiXC6f0RYF6kQDNBtdjpxybqbX0o4LmB8I/wkMt r2zgAMG+kwDmUqBoSK3/pWvZKHu2XTOxqaE4Ef8mJRGZSMJhu/VZbJSWMcx19hET0ghJEb Au4k+N0+B99aZtTQWmh6EdE8glj4uRM/HU6kv3d0cB1U6NanAiC0G/tXjIfcRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734622777; a=rsa-sha256; cv=none; b=yWWq6QfZ2Xi3BSuYPwSqFDiZt7sC1W/36/KaX3DvH8lEhHOAHMlk7dMnoQ8SZ8Dy1rJUoU IzD99dIimELbNkFfUtDAk7jShFP2arPYvhutlTxWJqKLxaZyIrSWlp4+4KK9RO9cQwf/yn BDqcqNGdn9Y3u2VExuCcaig+h4ORFrIXKYfIQdphCZ41wxM4jZswxZEXNpamDfRaDCxuME miK77aX0B4P6grP0OPY/EZuSwYuOZTd9uunXKcS7RH8K3O3m4kLvoWdFZlTTELoGmC+NqJ VYTt9Onp0H5qMAi4CXhJbLxrIT2QHZVO0zBjk1YPYsHRiFfM5/PXquRKKo6Fwg== 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 4YDZVK3m6xz10Vv; Thu, 19 Dec 2024 15:39:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BJFdbFp016396; Thu, 19 Dec 2024 15:39:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BJFdbbE016393; Thu, 19 Dec 2024 15:39:37 GMT (envelope-from git) Date: Thu, 19 Dec 2024 15:39:37 GMT Message-Id: <202412191539.4BJFdbbE016393@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 31034044ff27 - main - tcp: cleanup of nits after use of accessor tcp_get_flags List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 31034044ff27443489cb416ca520c07421712f69 Auto-Submitted: auto-generated The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=31034044ff27443489cb416ca520c07421712f69 commit 31034044ff27443489cb416ca520c07421712f69 Author: Richard Scheffenegger AuthorDate: 2024-12-19 13:47:32 +0000 Commit: Richard Scheffenegger CommitDate: 2024-12-19 15:37:24 +0000 tcp: cleanup of nits after use of accessor tcp_get_flags Remove unneeded th_x2 initalization, use named constants instead of magic numbers (fixing one oversight) and add some line breaks. Expand one man page slightly. No functional change intended. Reviewed By: tuexen, cc Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D48065 --- cddl/lib/libdtrace/tcp.d | 4 ++-- sbin/ipf/iplang/iplang_y.y | 3 ++- sbin/ipf/ipsend/ipsend.1 | 2 +- sbin/ipf/ipsend/ipsend.c | 2 +- sbin/ipf/ipsend/iptests.c | 3 +-- sbin/ipf/ipsend/resend.c | 2 +- sbin/ipf/libipf/ipft_tx.c | 10 ++++++---- sbin/ipf/libipf/printpacket.c | 4 ++-- usr.sbin/ppp/ip.c | 4 +--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d index 0df4e16d41d0..8f51675df305 100644 --- a/cddl/lib/libdtrace/tcp.d +++ b/cddl/lib/libdtrace/tcp.d @@ -97,7 +97,7 @@ inline uint16_t TH_ECE = 0x40; #pragma D binding "1.6.3" TH_CWR inline uint16_t TH_CWR = 0x80; #pragma D binding "1.6.3" TH_AE -inline uint16_t TH_AE = 0x100; +inline uint16_t TH_AE = 0x100; /* TCP connection state strings. */ #pragma D binding "1.6.3" tcp_state_string @@ -332,7 +332,7 @@ inline string tcpflag_string[uint16_t flags] = flags & TH_URG ? "URG" : flags & TH_ECE ? "ECE" : flags & TH_CWR ? "CWR" : - flags & TH_AE ? "AE" : + flags & TH_AE ? "AE" : "unknown" ; #pragma D binding "1.12.1" PRU_ATTACH diff --git a/sbin/ipf/iplang/iplang_y.y b/sbin/ipf/iplang/iplang_y.y index ce55ad277c1a..9e8ebf4e4312 100644 --- a/sbin/ipf/iplang/iplang_y.y +++ b/sbin/ipf/iplang/iplang_y.y @@ -1059,7 +1059,8 @@ void set_tcpflags(char **arg) __tcp_set_flags(tcp, strtol(*arg, NULL, 0)); break; } else - __tcp_set_flags(tcp, __tcp_get_flags(tcp) | flagv[t - flags]); + __tcp_set_flags(tcp, __tcp_get_flags(tcp) | + flagv[t - flags]); free(*arg); *arg = NULL; } diff --git a/sbin/ipf/ipsend/ipsend.1 b/sbin/ipf/ipsend/ipsend.1 index 57d29ba8569a..3cbb991694b1 100644 --- a/sbin/ipf/ipsend/ipsend.1 +++ b/sbin/ipf/ipsend/ipsend.1 @@ -39,7 +39,7 @@ ipsend \- sends IP packets packets to a destination host, using command line options to specify various attributes present in the headers. The \fIdestination\fP must be given as the last command line option, except for when TCP flags are specified as -a combination of A, S, F, U, P and R, last. +a combination of A, S, F, U, P, R, E, W and e, last. .PP The other way it may be compiled, with DOSOCKET defined, is to allow an attempt at making a TCP connection using a with ipsend resending the SYN diff --git a/sbin/ipf/ipsend/ipsend.c b/sbin/ipf/ipsend/ipsend.c index 2e2cf8f36fa2..78a8ccaa3f30 100644 --- a/sbin/ipf/ipsend/ipsend.c +++ b/sbin/ipf/ipsend/ipsend.c @@ -399,7 +399,7 @@ main(int argc, char **argv) printf("Source: %s\n", inet_ntoa(ip->ip_src)); printf("Dest: %s\n", inet_ntoa(ip->ip_dst)); printf("Gateway: %s\n", inet_ntoa(gwip)); - if (ip->ip_p == IPPROTO_TCP && __tcp_get_flags(tcp)) + if (ip->ip_p == IPPROTO_TCP && __tcp_get_flags(tcp) != 0) printf("Flags: %#x\n", __tcp_get_flags(tcp)); printf("mtu: %d\n", mtu); diff --git a/sbin/ipf/ipsend/iptests.c b/sbin/ipf/ipsend/iptests.c index eb8001b579d8..6f95970a83aa 100644 --- a/sbin/ipf/ipsend/iptests.c +++ b/sbin/ipf/ipsend/iptests.c @@ -903,7 +903,6 @@ ip_test5(char *dev, int mtu, ip_t *ip, struct in_addr gwip, int ptest) int nfd, i; t = (tcphdr_t *)((char *)ip + (IP_HL(ip) << 2)); - t->th_x2 = 0; TCP_OFF_A(t, 0); t->th_sport = htons(1); t->th_dport = htons(1); @@ -920,7 +919,7 @@ ip_test5(char *dev, int mtu, ip_t *ip, struct in_addr gwip, int ptest) if (!ptest || (ptest == 1)) { /* - * Test 1: flags variations, 0 - 3f + * Test 1: flags variations, 0 - 1ff */ TCP_OFF_A(t, sizeof(*t) >> 2); printf("5.1 Test TCP flag combinations\n"); diff --git a/sbin/ipf/ipsend/resend.c b/sbin/ipf/ipsend/resend.c index bbecf46e51c0..a306edddff19 100644 --- a/sbin/ipf/ipsend/resend.c +++ b/sbin/ipf/ipsend/resend.c @@ -50,7 +50,7 @@ dumppacket(ip_t *ip) if (ip->ip_p == IPPROTO_TCP) { printf(" seq %lu:%lu flags ", (u_long)t->th_seq, (u_long)t->th_ack); - for (j = 0, i = 1; i < 256; i *= 2, j++) + for (j = 0, i = 1; i < TH_FLAGS; i <<= 1, j++) if (__tcp_get_flags(t) & i) printf("%c", "FSRPAUEWe"[j]); } diff --git a/sbin/ipf/libipf/ipft_tx.c b/sbin/ipf/libipf/ipft_tx.c index 87e0fcb449d2..1e23f06be3fd 100644 --- a/sbin/ipf/libipf/ipft_tx.c +++ b/sbin/ipf/libipf/ipft_tx.c @@ -267,8 +267,9 @@ parseline(char *line, ip_t *ip, char **ifn, int *out) __tcp_set_flags(tcp, 0); for (s = *cpp; *s; s++) - if ((t = strchr(myflagset, *s))) - __tcp_set_flags(tcp, __tcp_get_flags(tcp) | myflags[t-myflagset]); + if ((t = strchr(myflagset, *s))) + __tcp_set_flags(tcp, __tcp_get_flags(tcp) | + myflags[t-myflagset]); if (__tcp_get_flags(tcp)) cpp++; } @@ -438,8 +439,9 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out) __tcp_set_flags(tcp, 0); for (s = *cpp; *s; s++) - if ((t = strchr(myflagset, *s))) - __tcp_set_flags(tcp, __tcp_get_flags(tcp) | myflags[t-myflagset]); + if ((t = strchr(myflagset, *s))) + __tcp_set_flags(tcp, __tcp_get_flags(tcp) | + myflags[t-myflagset]); if (__tcp_get_flags(tcp)) cpp++; } diff --git a/sbin/ipf/libipf/printpacket.c b/sbin/ipf/libipf/printpacket.c index 5d1d79bb4bb9..f8407c3a3102 100644 --- a/sbin/ipf/libipf/printpacket.c +++ b/sbin/ipf/libipf/printpacket.c @@ -13,7 +13,6 @@ # define IP_OFFMASK 0x3fff #endif - void printpacket(int dir, mb_t *m) { @@ -83,7 +82,8 @@ printpacket(int dir, mb_t *m) if (!(off & IP_OFFMASK)) { if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) PRINTF(",%d", ntohs(tcp->th_dport)); - if ((ip->ip_p == IPPROTO_TCP) && ((tcpflags = __tcp_get_flags(tcp)) != 0)) { + if ((ip->ip_p == IPPROTO_TCP) && + ((tcpflags = __tcp_get_flags(tcp)) != 0)) { putchar(' '); if (tcpflags & TH_FIN) putchar('F'); diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index b4c38f1933e5..aea1a812e2ea 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -829,13 +829,11 @@ PacketCheck(struct bundle *bundle, u_int32_t family, snprintf(logbuf + loglen, sizeof logbuf - loglen, "%s:%d", ncpaddr_ntoa(&dstaddr), ntohs(th->th_dport)); loglen += strlen(logbuf + loglen); - n = 0; - for (mask = TH_FIN; mask <= TH_FLAGS; mask <<= 1) { + for (mask = TH_FIN, n = 0; mask <= TH_FLAGS; mask <<= 1, n++) { if (__tcp_get_flags(th) & mask) { snprintf(logbuf + loglen, sizeof logbuf - loglen, " %s", TcpFlags[n]); loglen += strlen(logbuf + loglen); } - n++; } snprintf(logbuf + loglen, sizeof logbuf - loglen, " seq:%lx ack:%lx (%d/%d)",