Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 2023 09:39:07 GMT
From:      Eugene Grosbein <eugen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 20e1f207cc78 - main - ng_ipfw: allow use of 32 bits wide cookies
Message-ID:  <202311140939.3AE9d7wf085208@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=20e1f207cc789a28783344614d6d1d1c639c5797

commit 20e1f207cc789a28783344614d6d1d1c639c5797
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2023-11-14 09:36:08 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2023-11-14 09:36:08 +0000

    ng_ipfw: allow use of 32 bits wide cookies
    
    There is no reason in truncating 32 bits cookie value to 16 bits.
    
    Reviewed by:    glebius
    MFC after:      2 weeks
---
 sys/netgraph/ng_ipfw.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/sys/netgraph/ng_ipfw.c b/sys/netgraph/ng_ipfw.c
index b660a825c814..01592a4bbb7d 100644
--- a/sys/netgraph/ng_ipfw.c
+++ b/sys/netgraph/ng_ipfw.c
@@ -69,7 +69,7 @@ static ng_findhook_t	ng_ipfw_findhook;
 static ng_rcvdata_t	ng_ipfw_rcvdata;
 static ng_disconnect_t	ng_ipfw_disconnect;
 
-static hook_p		ng_ipfw_findhook1(node_p, u_int16_t );
+static hook_p		ng_ipfw_findhook1(node_p, uint32_t );
 static int	ng_ipfw_input(struct mbuf **, struct ip_fw_args *, bool);
 
 /* We have only one node */
@@ -94,7 +94,7 @@ MODULE_DEPEND(ng_ipfw, ipfw, 3, 3, 3);
 /* Information we store for each hook */
 struct ng_ipfw_hook_priv {
         hook_p		hook;
-	u_int16_t	rulenum;
+	uint32_t	cookie;
 };
 typedef struct ng_ipfw_hook_priv *hpriv_p;
 
@@ -152,7 +152,7 @@ static int
 ng_ipfw_newhook(node_p node, hook_p hook, const char *name)
 {
 	hpriv_p	hpriv;
-	u_int16_t rulenum;
+	uint32_t cookie;
 	const char *cp;
 	char *endptr;
 
@@ -166,7 +166,7 @@ ng_ipfw_newhook(node_p node, hook_p hook, const char *name)
 			return (EINVAL);
 
 	/* Convert it to integer */
-	rulenum = (u_int16_t)strtol(name, &endptr, 10);
+	cookie = (uint32_t)strtoul(name, &endptr, 10);
 	if (*endptr != '\0')
 		return (EINVAL);
 
@@ -176,7 +176,7 @@ ng_ipfw_newhook(node_p node, hook_p hook, const char *name)
 		return (ENOMEM);
 
 	hpriv->hook = hook;
-	hpriv->rulenum = rulenum;
+	hpriv->cookie = cookie;
 
 	NG_HOOK_SET_PRIVATE(hook, hpriv);
 
@@ -198,10 +198,10 @@ ng_ipfw_connect(hook_p hook)
 static hook_p
 ng_ipfw_findhook(node_p node, const char *name)
 {
-	u_int16_t n;	/* numeric representation of hook */
+	uint32_t n;	/* numeric representation of hook */
 	char *endptr;
 
-	n = (u_int16_t)strtol(name, &endptr, 10);
+	n = (uint32_t)strtoul(name, &endptr, 10);
 	if (*endptr != '\0')
 		return NULL;
 	return ng_ipfw_findhook1(node, n);
@@ -209,14 +209,14 @@ ng_ipfw_findhook(node_p node, const char *name)
 
 /* Look up hook by rule number */
 static hook_p
-ng_ipfw_findhook1(node_p node, u_int16_t rulenum)
+ng_ipfw_findhook1(node_p node, uint32_t cookie)
 {
 	hook_p	hook;
 	hpriv_p	hpriv;
 
 	LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
 		hpriv = NG_HOOK_PRIVATE(hook);
-		if (NG_HOOK_IS_VALID(hook) && (hpriv->rulenum == rulenum))
+		if (NG_HOOK_IS_VALID(hook) && (hpriv->cookie == cookie))
                         return (hook);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311140939.3AE9d7wf085208>