From nobody Thu Jun 15 06:50:09 2023 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 4QhXwf0k37z4dGGx; Thu, 15 Jun 2023 06:50:10 +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 4QhXwf0J4cz46CZ; Thu, 15 Jun 2023 06:50:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686811810; 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=dro98GS94BpsnwkRfCC+k5rQnZhe4590RajpHyj31dU=; b=cszg81FTi87Dky1rNkX3b4ZkWBtvxXULLht133wbOiqd7zDfriXE2WrEKesiaewXt6X5eR WkAcXW5EjSJQ2D1BufIQxFuQgNc/kPe/BwPNSm+clo2BhRJBD4j6sO9KLAXDFYspEoOofn vgLRl4MF8jZDcSzpSwdimfFsFXVMo1fL5Asvzz1s4OLvrwyIUUkdFMy+mIw1ZU9pxifmQv A/4lq+4FdNei2snSZi8h/5mzeriJXjr3kyoWRoSLCJpJZ0PmWmyhJtzCBsZC6Nt6i2cyJy uUMKBenGvgQbw6nrzHpqi2QpVK8FcdJE6V36LmWChUpioqagaznuRz7FfK3ERA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686811810; 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=dro98GS94BpsnwkRfCC+k5rQnZhe4590RajpHyj31dU=; b=NEfNznr6Qw2ynIXuNaWqixvIfURisAD1loLm/glZm9QTP/+INe44ugjvkDHHYy5bMk8qDj B21s0qPbpVBz22JKB77Q8DLTUqjgAR41kXfiGvD7QhN+xvRRT0dAORtDGdn48jvXhgTXra px+TgjWi5haN0GP9nTfnHhiVzsabgW2cbVE838l0LmZGhKNOYpqAiniCGjsl0UV9HmJfdQ tWyXrm6uJrvExqDZAk3zaRAUAF47zeJp2ydJEoZ19NnqyiNoedJgIeFDhpBb+aMEbB5sX/ pIVFFV+vJ70jBXE3d4NlnTHhTrQNG4i9mZ6oCUbibDmWPBpWo6qgoARtebOPCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686811810; a=rsa-sha256; cv=none; b=Xl82v684pQCjxHrVe3bBQYD1fZfLrUiaNurn3dwB3oaTH4cXh++7oenotYnwSAjb03MhEt zb04RNmsoHAic1G82TnjfVfpyBtAzQk/sveJMsQFsUQ1z0Y3bE0LneUvHT8ZnwH3L1cb/U aaGdZi21f02tNeW1LmZMYAyMCpFrZXPOh6UuCH9cktMYqTXFHJJsnUl80evGoLHW0xGFli XJpRyKqB18UkWvOh8qWZk0re4b35SJs+Qjrw2TaXV4dZXaypGn7NBHjrJ+LUt/0VgGCVGf uQj/0bSZfRxaErgPm+PphrwEgDk31XyiOg+BndtjfiO/QObgxnGvbfJZwvYaAw== 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 4QhXwd6Snszc4y; Thu, 15 Jun 2023 06:50:09 +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 35F6o974017497; Thu, 15 Jun 2023 06:50:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35F6o9wU017487; Thu, 15 Jun 2023 06:50:09 GMT (envelope-from git) Date: Thu, 15 Jun 2023 06:50:09 GMT Message-Id: <202306150650.35F6o9wU017487@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 2b5dd8b89011 - main - ipfw: use function return value to fetch insn argument. 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2b5dd8b89011098ff294dd58a5b61b087a4ef0b4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=2b5dd8b89011098ff294dd58a5b61b087a4ef0b4 commit 2b5dd8b89011098ff294dd58a5b61b087a4ef0b4 Author: Alexander V. Chernikov AuthorDate: 2023-06-15 06:46:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-06-15 06:46:42 +0000 ipfw: use function return value to fetch insn argument. This is a prerequsite for splitting compile_rule() into smaller chunks. MFC after: 2 weeks --- sbin/ipfw/ipfw2.c | 30 +++++++++++++----------------- sbin/ipfw/ipfw2.h | 2 +- sbin/ipfw/ipv6.c | 7 +++---- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index a711514cb5dc..95f70e882096 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -1203,8 +1203,8 @@ static struct _s_x icmpcodes[] = { { NULL, 0 } }; -static void -fill_reject_code(u_short *codep, char *str) +static uint16_t +get_reject_code(const char *str) { int val; char *s; @@ -1214,8 +1214,7 @@ fill_reject_code(u_short *codep, char *str) val = match_token(icmpcodes, str); if (val < 0) errx(EX_DATAERR, "unknown ICMP unreachable code ``%s''", str); - *codep = val; - return; + return (val); } static void @@ -3965,23 +3964,20 @@ arg_or_targ(const char *arg, const char *action) return (arg1); } -static void -fill_divert_port(ipfw_insn *cmd, char *arg, const char *action) +static uint16_t +get_divert_port(const char *arg, const char *action) { uint32_t arg1 = arg_or_targ_relaxed(arg, action); - if (arg1 != (uint32_t)(-1)) { - cmd->arg1 = arg1; - return; - } + if (arg1 != (uint32_t)(-1)) + return (arg1); struct servent *s; setservent(1); s = getservbyname(arg, "divert"); - if (s != NULL) - cmd->arg1 = ntohs(s->s_port); - else + if (s == NULL) errx(EX_DATAERR, "illegal divert/tee port"); + return (ntohs(s->s_port)); } /* @@ -4143,7 +4139,7 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate) case TOK_UNREACH: action->opcode = O_REJECT; NEED1("missing reject code"); - fill_reject_code(&action->arg1, *av); + action->arg1 = get_reject_code(*av); av++; if (action->arg1 == ICMP_UNREACH_NEEDFRAG && isdigit(**av)) { uint16_t mtu; @@ -4161,7 +4157,7 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate) case TOK_UNREACH6: action->opcode = O_UNREACH6; NEED1("missing unreach code"); - fill_unreach6_code(&action->arg1, *av); + action->arg1 = get_unreach6_code(*av); av++; break; @@ -4206,12 +4202,12 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate) break; case TOK_DIVERT: action->opcode = O_DIVERT; - fill_divert_port(action, av[0], *(av - 1)); + action->arg1 = get_divert_port(av[0], *(av - 1)); av++; break; case TOK_TEE: action->opcode = O_TEE; - fill_divert_port(action, av[0], *(av - 1)); + action->arg1 = get_divert_port(av[0], *(av - 1)); av++; break; case TOK_CALL: diff --git a/sbin/ipfw/ipfw2.h b/sbin/ipfw/ipfw2.h index 92fa05ae14b2..f787bbbb714d 100644 --- a/sbin/ipfw/ipfw2.h +++ b/sbin/ipfw/ipfw2.h @@ -448,7 +448,7 @@ struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av, int cblen, struct tidx *tstate); void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av, int cblen); -void fill_unreach6_code(u_short *codep, char *str); +uint16_t get_unreach6_code(const char *str); void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av, int cblen); int fill_ext6hdr(struct _ipfw_insn *cmd, char *av); diff --git a/sbin/ipfw/ipv6.c b/sbin/ipfw/ipv6.c index eea313572f34..7cb12127548b 100644 --- a/sbin/ipfw/ipv6.c +++ b/sbin/ipfw/ipv6.c @@ -55,8 +55,8 @@ static struct _s_x icmp6codes[] = { { NULL, 0 } }; -void -fill_unreach6_code(u_short *codep, char *str) +uint16_t +get_unreach6_code(const char *str) { int val; char *s; @@ -66,8 +66,7 @@ fill_unreach6_code(u_short *codep, char *str) val = match_token(icmp6codes, str); if (val < 0) errx(EX_DATAERR, "unknown ICMPv6 unreachable code ``%s''", str); - *codep = val; - return; + return (val); } void