From 8a5caee4021b6d586d8b1bbd4e1a4219f2841de0 Mon Sep 17 00:00:00 2001 From: glebius Date: Thu, 14 Mar 2019 22:30:05 +0000 Subject: [PATCH] Remove 'dir' argument in ng_ipfw_input, since ip_fw_args now has this info. While here make 'tee' boolean. --- sys/netgraph/ng_ipfw.c | 10 +++++----- sys/netinet/ip_var.h | 4 +--- sys/netinet/raw_ip.c | 3 +-- sys/netpfil/ipfw/ip_fw_pfil.c | 6 ++---- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/sys/netgraph/ng_ipfw.c b/sys/netgraph/ng_ipfw.c index c7d24c8d4f4..59983373132 100644 --- a/sys/netgraph/ng_ipfw.c +++ b/sys/netgraph/ng_ipfw.c @@ -72,8 +72,7 @@ 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 int ng_ipfw_input(struct mbuf **, int, struct ip_fw_args *, - int); +static int ng_ipfw_input(struct mbuf **, struct ip_fw_args *, bool); /* We have only one node */ static node_p fw_node; @@ -285,7 +284,7 @@ ng_ipfw_rcvdata(hook_p hook, item_p item) } static int -ng_ipfw_input(struct mbuf **m0, int dir, struct ip_fw_args *fwa, int tee) +ng_ipfw_input(struct mbuf **m0, struct ip_fw_args *fwa, bool tee) { struct mbuf *m; hook_p hook; @@ -303,7 +302,7 @@ ng_ipfw_input(struct mbuf **m0, int dir, struct ip_fw_args *fwa, int tee) * important to return packet back to IP stack. In tee mode we make * a copy of a packet and forward it into netgraph without a tag. */ - if (tee == 0) { + if (tee == false) { struct m_tag *tag; struct ipfw_rule_ref *r; m = *m0; @@ -318,7 +317,8 @@ ng_ipfw_input(struct mbuf **m0, int dir, struct ip_fw_args *fwa, int tee) r = (struct ipfw_rule_ref *)(tag + 1); *r = fwa->rule; r->info &= IPFW_ONEPASS; /* keep this info */ - r->info |= dir ? IPFW_INFO_IN : IPFW_INFO_OUT; + r->info |= (fwa->flags & IPFW_ARGS_IN) ? + IPFW_INFO_IN : IPFW_INFO_OUT; m_tag_prepend(m, tag); } else diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index ee8b864c56d..56566e67f84 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -294,9 +294,7 @@ VNET_DECLARE(ip_fw_ctl_ptr_t, ip_fw_ctl_ptr); /* Divert hooks. */ extern void (*ip_divert_ptr)(struct mbuf *m, bool incoming); /* ng_ipfw hooks -- XXX make it the same as divert and dummynet */ -extern int (*ng_ipfw_input_p)(struct mbuf **, int, - struct ip_fw_args *, int); - +extern int (*ng_ipfw_input_p)(struct mbuf **, struct ip_fw_args *, bool); extern int (*ip_dn_ctl_ptr)(struct sockopt *); extern int (*ip_dn_io_ptr)(struct mbuf **, int, struct ip_fw_args *); #endif /* _KERNEL */ diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 4ca3b3ecc3c..c4d218a9d4f 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -102,8 +102,7 @@ VNET_DEFINE(ip_fw_ctl_ptr_t, ip_fw_ctl_ptr) = NULL; int (*ip_dn_ctl_ptr)(struct sockopt *); int (*ip_dn_io_ptr)(struct mbuf **, int, struct ip_fw_args *); void (*ip_divert_ptr)(struct mbuf *, bool); -int (*ng_ipfw_input_p)(struct mbuf **, int, - struct ip_fw_args *, int); +int (*ng_ipfw_input_p)(struct mbuf **, struct ip_fw_args *, bool); #ifdef INET /* diff --git a/sys/netpfil/ipfw/ip_fw_pfil.c b/sys/netpfil/ipfw/ip_fw_pfil.c index f8fdc3b7978..d08e60c008c 100644 --- a/sys/netpfil/ipfw/ip_fw_pfil.c +++ b/sys/netpfil/ipfw/ip_fw_pfil.c @@ -296,8 +296,7 @@ ipfw_check_packet(struct mbuf **m0, struct ifnet *ifp, int flags, break; } MPASS(args.flags & IPFW_ARGS_REF); - (void )ng_ipfw_input_p(m0, dir, &args, - (ipfw == IP_FW_NGTEE) ? 1 : 0); + (void )ng_ipfw_input_p(m0, &args, ipfw == IP_FW_NGTEE); if (ipfw == IP_FW_NGTEE) /* ignore errors for NGTEE */ goto again; /* continue with packet */ ret = PFIL_CONSUMED; @@ -421,8 +420,7 @@ ipfw_check_frame(struct mbuf **m0, struct ifnet *ifp, int dir, break; } MPASS(args.flags & IPFW_ARGS_REF); - (void )ng_ipfw_input_p(m0, (dir & PFIL_IN) ? DIR_IN : DIR_OUT, - &args, (i == IP_FW_NGTEE) ? 1 : 0); + (void )ng_ipfw_input_p(m0, &args, i == IP_FW_NGTEE); if (i == IP_FW_NGTEE) /* ignore errors for NGTEE */ goto again; /* continue with packet */ ret = PFIL_CONSUMED; -- 2.45.0