PERFORCE change 144239 for review

Gleb Kurtsou gk at FreeBSD.org
Sat Jun 28 20:42:55 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144239

Change 144239 by gk at gk_h1 on 2008/06/28 20:42:31

	Fix creation of dynamic rules with ether address specified in table

Affected files ...

.. //depot/projects/soc2008/gk_l2filter/sys-netinet/ip_fw2.c#10 edit

Differences ...

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/ip_fw2.c#10 (text+ko) ====

@@ -1904,7 +1904,7 @@
 
 static int
 lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
-    struct ether_addr *ea, uint32_t *val)
+    struct ether_addr *ea, ipfw_ether_addr *val_ea, uint32_t *val)
 {
 	struct radix_node_head *rnh;
 	struct table_entry *ent;
@@ -1918,7 +1918,9 @@
 	ent = (struct table_entry *)(rnh->rnh_lookup(&sa, NULL, rnh));
 	if (ent != NULL) {
 		if (ea && !ether_addr_allow(&ent->ether_addr, ea))
-				return (0);
+			return (0);
+		/* use address to create dynamic rule */
+		*val_ea = ent->ether_addr;
 		*val = ent->value;
 		return (1);
 	}
@@ -2709,12 +2711,15 @@
 				    uint32_t v;
 
 				    if (args->eh) {
-					    ea = (struct ether_addr*)((cmd->opcode == O_IP_DST_LOOKUP) ?
-						    args->eh->ether_dhost :
-						    args->eh->ether_shost);
+					ea = (struct ether_addr*)((cmd->opcode == O_IP_DST_LOOKUP) ?
+					    args->eh->ether_dhost :
+					    args->eh->ether_shost);
 				    }
 				    match = lookup_table(chain, cmd->arg1, a,
-					ea, &v);
+					ea, (cmd->opcode == O_IP_DST_LOOKUP ?
+						&args->f_id.dst_ether :
+						&args->f_id.src_ether),
+					&v);
 				    if (!match)
 					break;
 				    if (cmdlen == F_INSN_SIZE(ipfw_insn_u32))


More information about the p4-projects mailing list