svn commit: r204349 - in user/luigi/ipfw3-head: sbin/ipfw sys/netinet/ipfw

Luigi Rizzo luigi at FreeBSD.org
Fri Feb 26 07:22:02 UTC 2010


Author: luigi
Date: Fri Feb 26 07:22:01 2010
New Revision: 204349
URL: http://svn.freebsd.org/changeset/base/204349

Log:
  diff reduction

Modified:
  user/luigi/ipfw3-head/sbin/ipfw/main.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c

Modified: user/luigi/ipfw3-head/sbin/ipfw/main.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/main.c	Fri Feb 26 07:08:44 2010	(r204348)
+++ user/luigi/ipfw3-head/sbin/ipfw/main.c	Fri Feb 26 07:22:01 2010	(r204349)
@@ -240,7 +240,7 @@ ipfw_main(int oldac, char **oldav)
 				"	ipfw sysctl -a\n");
 			return 0;
 		}
-		s = index(av[2], '=')) {
+		s = index(av[2], '=');
 		if (s == NULL) {
 			s = !strcmp(av[2], "-a") ? NULL : av[2];
 			sysctlbyname(s, NULL, NULL, NULL, 0);

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Feb 26 07:08:44 2010	(r204348)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Fri Feb 26 07:22:01 2010	(r204349)
@@ -790,8 +790,13 @@ copy_obj(char **start, char *end, void *
 	if (o->type == DN_LINK) {
 		/* Adjust burst parameter for link */
 		struct dn_link *l = (struct dn_link *)*start;
-		/* XXX marta: check what is meant here, div64 or what */
 		l->burst =  div64(l->burst, 8 * hz);
+	} else if (o->type == DN_SCH) {
+		/* Set id->id to the number of instances */
+		struct dn_schk *s = _o;
+		struct dn_id *id = (struct dn_id *)(*start);
+		id->id = (s->sch.flags & DN_HAVE_MASK) ?
+			dn_ht_entries(s->siht) : (s->siht ? 1 : 0);
 	}
 	*start += o->len;
 	return 0;
@@ -964,6 +969,7 @@ copy_data_helper(void *_o, void *_arg)
 			if (copy_obj(a->start, a->end, &s->sch,
 					"sched", s->sch.sched_nr))
 				return DNHT_SCAN_END;
+
 			/* list all attached flowsets */
 			if (copy_fsk_list(a, s, 0))
 				return DNHT_SCAN_END;
@@ -1600,7 +1606,7 @@ do_config(void *p, int l)
 		 * handler and return
 		 */
 		case DN_SYSCTL_SET:
-			err = kesysctl_set_w32(p);
+			err = kesysctl_emu_set(p, l);
 			return err;
 #endif
 		case DN_CMD_CONFIG: /* simply a header */
@@ -1748,9 +1754,9 @@ compute_space(struct dn_id *cmd, int *to
 int
 dummynet_get(struct sockopt *sopt, void **compat)
 {
-	int have, i, need, error = 0;
+	int have, i, need, error;
 	char *start = NULL, *buf;
-	size_t sopt_valsize = 0;
+	size_t sopt_valsize;
 	struct dn_id cmd;
 	struct copy_args a;
 
@@ -1758,21 +1764,16 @@ dummynet_get(struct sockopt *sopt, void 
 	sopt_valsize = sopt->sopt_valsize;
 	if (!compat) {
 		error = sooptcopyin(sopt, &cmd, sizeof(cmd), sizeof(cmd));
-#ifdef EMULATE_SYSCTL
-		/* sysctl emulation.
-		 * if we recognize the command, jump to the correct
-		 * handler and return
-		 */
-		if (cmd.type == DN_SYSCTL_GET) {
-			//jump to sysctl handler
-			error = kesysctl_get_w32(sopt);
-			return error;
-		}
-#endif
-		sopt->sopt_valsize = sopt_valsize;
 		if (error)
 			return error;
+		sopt->sopt_valsize = sopt_valsize;
+#ifdef EMULATE_SYSCTL
+		/* sysctl emulation. */
+		if (cmd.type == DN_SYSCTL_GET)
+			return kesysctl_emu_get(sopt);
+#endif
 	} else {
+		error = 0;
 		cmd.type = DN_CMD_GET;
 		cmd.len = sizeof(struct dn_id);
 		cmd.subtype = DN_GET_COMPAT;
@@ -1822,8 +1823,8 @@ dummynet_get(struct sockopt *sopt, void 
 	sopt->sopt_valsize = sopt_valsize;
 	a.type = cmd.subtype;
 	if (compat == NULL) {
-	bcopy(&cmd, start, sizeof(cmd));
-	buf = start + sizeof(cmd);
+		bcopy(&cmd, start, sizeof(cmd));
+		buf = start + sizeof(cmd);
 	} else
 		buf = start;
 	a.start = &buf;
@@ -1843,11 +1844,9 @@ dummynet_get(struct sockopt *sopt, void 
 		*compat = start;
 		sopt->sopt_valsize = buf - start;
 		/* free() is done by ip_dummynet_compat() */
-		return 0;
-	}
-	else {
-	error = sooptcopyout(sopt, start, buf - start);
-	free(start, M_DUMMYNET);
+	} else {
+		error = sooptcopyout(sopt, start, buf - start);
+		free(start, M_DUMMYNET);
 	}
 	return error;
 }

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c	Fri Feb 26 07:08:44 2010	(r204348)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c	Fri Feb 26 07:22:01 2010	(r204349)
@@ -142,6 +142,9 @@ ipfw_nat_cfg_t *ipfw_nat_get_cfg_ptr;
 ipfw_nat_cfg_t *ipfw_nat_get_log_ptr;
 
 #ifdef SYSCTL_NODE
+uint32_t dummy_def = IPFW_DEFAULT_RULE;
+uint32_t dummy_tables_max = IPFW_TABLES_MAX;
+
 SYSCTL_NODE(_net_inet_ip, OID_AUTO, fw, CTLFLAG_RW, 0, "Firewall");
 SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, one_pass,
     CTLFLAG_RW | CTLFLAG_SECURE3, &VNET_NAME(fw_one_pass), 0,
@@ -155,11 +158,9 @@ SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUT
 SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, verbose_limit,
     CTLFLAG_RW, &VNET_NAME(verbose_limit), 0,
     "Set upper limit of matches of ipfw rules logged");
-uint32_t dummy_def = IPFW_DEFAULT_RULE;
 SYSCTL_UINT(_net_inet_ip_fw, OID_AUTO, default_rule, CTLFLAG_RD,
     &dummy_def, 0,
     "The default/max possible rule number.");
-uint32_t dummy_tables_max = IPFW_TABLES_MAX;
 SYSCTL_UINT(_net_inet_ip_fw, OID_AUTO, tables_max, CTLFLAG_RD,
     &dummy_tables_max, 0,
     "The maximum number of tables.");


More information about the svn-src-user mailing list