From nobody Mon May 20 20:38:33 2024 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 4VjqCY6RHHz5LP9d; Mon, 20 May 2024 20:38:33 +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 4VjqCY5lsVz4RVw; Mon, 20 May 2024 20:38:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716237513; 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=6tMX9vng1NBmZx6k/T8u0gDpGDM6aWaOh+Q4cgRv0mY=; b=xSHex30IH5YWDcFhaEDCKMJYzGDy1ygJetHTpPcaseLJBDCXgLcGX+1XvonUqQ3DVGVPgE tqbvI/Kvac93ix9kA5MqhTTeNV3zr4iWtzuHm5I4lQ6fkORRzM2wrfKOlm3xF2BcSMDo/2 J9EwNBokQDiKhuqR5RcvbsJns2/Ee6m+8uQ+eelOlCXqF/cEG8WnkbCsp68ZTRW33RRGsy 253tgEd0vcAMukVNgKGJXXb7Db6q2FkprnoPUvMZHGurWRrt1botGQU5rKgL0Bbro22RkU is/T1wzHdc9vhFIXvZDYeLFB0k6GVfgEIm/4a2Pzl73OR8PhGogGuTaVmtCz8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716237513; a=rsa-sha256; cv=none; b=ON3EbXtBoxZwGhk0FxaB90jXA7rR/sxrEiLZWxyY1YHK3XFNBB/sPtI2WdKHDZ4yxgvO5U YQRVpjwv1lBl62rmU2X3T/3Q8oLy7tOt4rCApW7ms5g0iV5S9BsLyeFwg4hcygpIekLxkj lHrsZVmtxdqrQ5tKXh3Ht97uwGm8N+cctMlSp/4jsYBqp3t4er/cixsT+wjxEKJGdn6o6f 4h6WK9euGUwBAQROGrPjbpF0UdpTx+9A3SGu8jIRIvCxCPv1yVNALE7cakSNvzPpIQRYh2 Nb2VVF4WmpWX5hilsa13dqBDCuUSmgZWklkbGMmrhapuMaCqWNp0IU8lEk6AHw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716237513; 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=6tMX9vng1NBmZx6k/T8u0gDpGDM6aWaOh+Q4cgRv0mY=; b=udTxmgHdDdRcYFhdCcUp2aO/GOsJ1Qw0zQx+rlSTOUj6XXJXUP4B/zZFvy7t6AlhToM5PP NwRCQihVvaSSEr59iA9RF+Fg3mypSl/yGALIacxixHPuk3go9gUU//csRncZBckruBWmf7 R7vmOHltlLGRN/m2K4fkEI3KGVypYwHIRGVXkHkOAQp3kTVr74JlA9qaWnytCN/HkWrvFX rf8ub6oCapZqVsT/Bdj5oGj1ux0ADOx8EZrkqJ7zB+CHqPk844iiBP+158svsnApZcT6n/ 0qSzHZEU/xUePbN6d6QfmgxNawNesZDGijF/UfgbZigyYvb38YeTVWbpWob4Zg== 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 4VjqCY58ynzsxm; Mon, 20 May 2024 20:38:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44KKcXai057573; Mon, 20 May 2024 20:38:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44KKcXeM057570; Mon, 20 May 2024 20:38:33 GMT (envelope-from git) Date: Mon, 20 May 2024 20:38:33 GMT Message-Id: <202405202038.44KKcXeM057570@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: f44abb705590 - releng/14.1 - ifconfig: Add format shortcuts. 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.1 X-Git-Reftype: branch X-Git-Commit: f44abb7055904b5d7ea2ce984abccd3098a54987 Auto-Submitted: auto-generated The branch releng/14.1 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=f44abb7055904b5d7ea2ce984abccd3098a54987 commit f44abb7055904b5d7ea2ce984abccd3098a54987 Author: Dag-Erling Smørgrav AuthorDate: 2024-05-14 06:51:42 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-05-20 20:37:28 +0000 ifconfig: Add format shortcuts. MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D45166 (cherry picked from commit 847ef59d4b5eab234bd1f8eb947ad74bdab5614e) ifconfig: Markup nits. MFC after: 3 days Reviewed by: imp, allanjude Differential Revision: https://reviews.freebsd.org/D45209 (cherry picked from commit 42b28f815214aa582fe4ca707687d3af47850230) (cherry picked from commit dd1a16c9e2c1c95d9ac7ad0b082248e60ede0e99) Approved by: re (cperciva) --- sbin/ifconfig/ifconfig.8 | 32 +++++++++++++++++++++++--------- sbin/ifconfig/ifconfig.c | 42 +++++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index a538981608cd..471d37ac1779 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -27,7 +27,7 @@ .\" .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" -.Dd November 08, 2023 +.Dd May 12, 2024 .Dt IFCONFIG 8 .Os .Sh NAME @@ -137,7 +137,7 @@ and their associated .Ar format strings are: .Pp -.Bl -tag -width ether +.Bl -tag -width default .It Cm addr Adjust the display of inet and inet6 addresses: .Pp @@ -202,6 +202,16 @@ Integer format, for example: .Ql prefixlen 64 .El .El +.Pp +In addition, the following shortcuts are accepted: +.Bl -tag -width default +.It Cm default +Resets all formats to their default values. +.It Cm cidr +Shortcut notation for +.Cm inet:cidr,inet6:cidr . +.El +.Pp .It Fl G Ar groupname Exclude members of the specified .Ar groupname @@ -464,13 +474,17 @@ sending out requests and listening for replies. .It Cm stickyarp Enable the so-called sticky ARP mode for the interface. If this option is enabled on the given interface, any resolved address is -marked as a static one and never expires. This may be used to increase +marked as a static one and never expires. +This may be used to increase security of the network by preventing ARP spoofing or to reduce latency for high-performance Ethernet networks where the time needed for ARP resolution is -too high. Please note that a similar feature is also provided for bridges. See +too high. +Please note that a similar feature is also provided for bridges. +See the sticky option in the .Sx Bridge Interface Parameters -section. Enabling this +section. +Enabling this option may impact techniques which rely on ARP expiration/overwriting feature such as load-balancers or high-availabity solutions such as .Xr carp 4 . @@ -1227,8 +1241,8 @@ Set the interval at which beacon frames are sent when operating in ad-hoc or ap mode. The .Ar interval -parameter is specified in TU's (1024 usecs). -By default beacon frames are transmitted every 100 TU's. +parameter is specified in TUs (1024 usecs). +By default beacon frames are transmitted every 100 TUs. .It Cm bmissthreshold Ar count Set the number of consecutive missed beacons at which the station will attempt to roam (i.e., search for a new access point). @@ -1885,8 +1899,8 @@ Use .Fl powersave to disable powersave operation when operating as a client. .It Cm powersavesleep Ar sleep -Set the desired max powersave sleep time in TU's (1024 usecs). -By default the max powersave sleep time is 100 TU's. +Set the desired max powersave sleep time in TUs (1024 usecs). +By default the max powersave sleep time is 100 TUs. .It Cm protmode Ar technique For interfaces operating in 802.11g, use the specified .Ar technique diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 7a78e9a934f7..402967d405fd 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -322,14 +322,10 @@ cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q) static void freeformat(void) { - if (f_inet != NULL) - free(f_inet); - if (f_inet6 != NULL) - free(f_inet6); - if (f_ether != NULL) - free(f_ether); - if (f_addr != NULL) - free(f_addr); + free(f_inet); + free(f_inet6); + free(f_ether); + free(f_addr); } static void setformat(char *input) @@ -339,9 +335,18 @@ static void setformat(char *input) formatstr = strdup(input); while ((category = strsep(&formatstr, ",")) != NULL) { modifier = strchr(category, ':'); - if (modifier == NULL || modifier[1] == '\0') { - warnx("Skipping invalid format specification: %s\n", - category); + if (modifier == NULL) { + if (strcmp(category, "default") == 0) { + freeformat(); + } else if (strcmp(category, "cidr") == 0) { + free(f_inet); + f_inet = strdup(category); + free(f_inet6); + f_inet6 = strdup(category); + } else { + warnx("Skipping invalid format: %s\n", + category); + } continue; } @@ -349,14 +354,19 @@ static void setformat(char *input) modifier[0] = '\0'; modifier++; - if (strcmp(category, "addr") == 0) + if (strcmp(category, "addr") == 0) { + free(f_addr); f_addr = strdup(modifier); - else if (strcmp(category, "ether") == 0) + } else if (strcmp(category, "ether") == 0) { + free(f_ether); f_ether = strdup(modifier); - else if (strcmp(category, "inet") == 0) + } else if (strcmp(category, "inet") == 0) { + free(f_inet); f_inet = strdup(modifier); - else if (strcmp(category, "inet6") == 0) + } else if (strcmp(category, "inet6") == 0) { + free(f_inet6); f_inet6 = strdup(modifier); + } } free(formatstr); } @@ -621,8 +631,6 @@ main(int ac, char *av[]) .io_s = -1, }; - f_inet = f_inet6 = f_ether = f_addr = NULL; - lifh = ifconfig_open(); if (lifh == NULL) err(EXIT_FAILURE, "ifconfig_open");