Révision 8192ddc4
Ajouté par Ermal il y a presque 10 ans
patches/stable/10/CP_speedup.diff | ||
---|---|---|
767 | 767 |
{ |
768 | 768 |
ipfw_xtable *tbl; |
769 | 769 |
diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c |
770 |
index 95cff5c..971d257 100644
|
|
770 |
index 95cff5c..5c00420 100644
|
|
771 | 771 |
--- a/sys/netpfil/ipfw/ip_fw_table.c |
772 | 772 |
+++ b/sys/netpfil/ipfw/ip_fw_table.c |
773 | 773 |
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); |
... | ... | |
998 | 998 |
default: |
999 | 999 |
return (EINVAL); |
1000 | 1000 |
} |
1001 |
@@ -552,9 +688,157 @@ ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
|
|
1001 |
@@ -552,9 +688,199 @@ ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
|
|
1002 | 1002 |
return (0); |
1003 | 1003 |
} |
1004 | 1004 |
|
... | ... | |
1012 | 1012 |
+ xent->timestamp = time_uptime; |
1013 | 1013 |
+} |
1014 | 1014 |
+ |
1015 |
+int
|
|
1015 |
int
|
|
1016 | 1016 |
+ipfw_zero_table_xentry_stats(struct ip_fw_chain *ch, ipfw_table_xentry *arg) |
1017 | 1017 |
+{ |
1018 | 1018 |
+ struct radix_node_head *rnh; |
... | ... | |
1023 | 1023 |
+ |
1024 | 1024 |
+ if (arg->tbl >= V_fw_tables_max) |
1025 | 1025 |
+ return (0); |
1026 |
+ if ((rnh = ch->xtables[arg->tbl]) == NULL) |
|
1026 |
+ if (ch->tables[arg->tbl] != NULL) |
|
1027 |
+ rnh = ch->tables[arg->tbl]; |
|
1028 |
+ else if (ch->xtables[arg->tbl] != NULL) |
|
1029 |
+ rnh = ch->xtables[arg->tbl]; |
|
1030 |
+ else |
|
1027 | 1031 |
+ return (0); |
1028 | 1032 |
+ |
1029 | 1033 |
+ switch (arg->type) { |
1030 | 1034 |
+ case IPFW_TABLE_CIDR: |
1031 |
+ KEY_LEN(sa6) = KEY_LEN_INET6; |
|
1032 |
+ memcpy(&sa6.sin6_addr, &arg->k.addr6, sizeof(struct in6_addr)); |
|
1033 |
+ xent = (struct table_xentry *)(rnh->rnh_lookup(&sa6, NULL, rnh)); |
|
1035 |
+ if (ch->tables[arg->tbl] != NULL) { |
|
1036 |
+ /* XXX: Maybe better by FreeBSD 11!! */ |
|
1037 |
+ struct sockaddr_in sa; |
|
1038 |
+ struct table_entry *ent; |
|
1039 |
+ |
|
1040 |
+ KEY_LEN(sa) = KEY_LEN_INET; |
|
1041 |
+ sa.sin_addr.s_addr = *((in_addr_t *)arg->k); |
|
1042 |
+ ent = (struct table_entry *)(rnh->rnh_lookup(&sa, NULL, rnh)); |
|
1043 |
+ if (ent == NULL) |
|
1044 |
+ return (0); |
|
1045 |
+ |
|
1046 |
+ arg->bytes = 0; |
|
1047 |
+ arg->packets = 0; |
|
1048 |
+ arg->value = ent->value; |
|
1049 |
+ arg->timestamp = time_uptime; |
|
1050 |
+ |
|
1051 |
+ return (1); |
|
1052 |
+ } else { |
|
1053 |
+ KEY_LEN(sa6) = KEY_LEN_INET6; |
|
1054 |
+ memcpy(&sa6.sin6_addr, &arg->k.addr6, sizeof(struct in6_addr)); |
|
1055 |
+ xent = (struct table_xentry *)(rnh->rnh_lookup(&sa6, NULL, rnh)); |
|
1056 |
+ } |
|
1034 | 1057 |
+ break; |
1035 | 1058 |
+ |
1036 | 1059 |
+ case IPFW_TABLE_INTERFACE: |
... | ... | |
1074 | 1097 |
+ return (0); |
1075 | 1098 |
+} |
1076 | 1099 |
+ |
1077 |
int
|
|
1100 |
+int
|
|
1078 | 1101 |
+ipfw_lookup_table_xentry(struct ip_fw_chain *ch, ipfw_table_xentry *arg) |
1079 | 1102 |
+{ |
1080 | 1103 |
+ struct radix_node_head *rnh; |
... | ... | |
1092 | 1115 |
+ switch (arg->type) { |
1093 | 1116 |
+ case IPFW_TABLE_CIDR: |
1094 | 1117 |
+ { |
1095 |
+ struct sockaddr_in6 sa6; |
|
1096 |
+ KEY_LEN(sa6) = KEY_LEN_INET6; |
|
1097 |
+ memcpy(&sa6.sin6_addr, &arg->k.addr6, sizeof(struct in6_addr)); |
|
1098 |
+ xent = (struct table_xentry *)(rnh->rnh_lookup(&sa6, NULL, rnh)); |
|
1118 |
+ if (ch->tables[arg->tbl] != NULL) { |
|
1119 |
+ /* XXX: Maybe better by FreeBSD 11!! */ |
|
1120 |
+ struct sockaddr_in sa; |
|
1121 |
+ struct table_entry *ent; |
|
1122 |
+ |
|
1123 |
+ KEY_LEN(sa) = KEY_LEN_INET; |
|
1124 |
+ sa.sin_addr.s_addr = *((in_addr_t *)arg->k); |
|
1125 |
+ ent = (struct table_entry *)(rnh->rnh_lookup(&sa, NULL, rnh)); |
|
1126 |
+ if (ent == NULL) |
|
1127 |
+ return (0); |
|
1128 |
+ |
|
1129 |
+ arg->bytes = ent->bytes; |
|
1130 |
+ arg->packets = ent->packets; |
|
1131 |
+ arg->value = ent->value; |
|
1132 |
+ arg->timestamp = ent->timestamp; |
|
1133 |
+ arg->mac_addr = ent->mac_addr; |
|
1134 |
+ return (1); |
|
1135 |
+ } else { |
|
1136 |
+ struct sockaddr_in6 sa6; |
|
1137 |
+ KEY_LEN(sa6) = KEY_LEN_INET6; |
|
1138 |
+ memcpy(&sa6.sin6_addr, &arg->k.addr6, sizeof(struct in6_addr)); |
|
1139 |
+ xent = (struct table_xentry *)(rnh->rnh_lookup(&sa6, NULL, rnh)); |
|
1140 |
+ } |
|
1099 | 1141 |
+ } |
1100 | 1142 |
+ break; |
1101 | 1143 |
+ |
... | ... | |
1157 | 1199 |
{ |
1158 | 1200 |
struct radix_node_head *rnh; |
1159 | 1201 |
struct table_xentry *xent; |
1160 |
@@ -562,15 +846,21 @@ ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, void *paddr,
|
|
1202 |
@@ -562,15 +888,21 @@ ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, void *paddr,
|
|
1161 | 1203 |
struct xaddr_iface iface; |
1162 | 1204 |
|
1163 | 1205 |
if (tbl >= V_fw_tables_max) |
... | ... | |
1181 | 1223 |
break; |
1182 | 1224 |
|
1183 | 1225 |
case IPFW_TABLE_INTERFACE: |
1184 |
@@ -581,15 +871,37 @@ ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, void *paddr,
|
|
1226 |
@@ -581,15 +913,37 @@ ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, void *paddr,
|
|
1185 | 1227 |
xent = (struct table_xentry *)(rnh->rnh_lookup(&iface, NULL, rnh)); |
1186 | 1228 |
break; |
1187 | 1229 |
|
... | ... | |
1222 | 1264 |
} |
1223 | 1265 |
|
1224 | 1266 |
static int |
1225 |
@@ -697,7 +1009,12 @@ dump_table_xentry_base(struct radix_node *rn, void *arg)
|
|
1267 |
@@ -697,7 +1051,12 @@ dump_table_xentry_base(struct radix_node *rn, void *arg)
|
|
1226 | 1268 |
xent->masklen = 33 - ffs(ntohl(n->mask.sin_addr.s_addr)); |
1227 | 1269 |
/* Save IPv4 address as deprecated IPv6 compatible */ |
1228 | 1270 |
xent->k.addr6.s6_addr32[3] = n->addr.sin_addr.s_addr; |
... | ... | |
1235 | 1277 |
tbl->cnt++; |
1236 | 1278 |
return (0); |
1237 | 1279 |
} |
1238 |
@@ -735,12 +1052,31 @@ dump_table_xentry_extended(struct radix_node *rn, void *arg)
|
|
1280 |
@@ -735,12 +1094,31 @@ dump_table_xentry_extended(struct radix_node *rn, void *arg)
|
|
1239 | 1281 |
memcpy(&xent->k, &n->a.iface.ifname, IF_NAMESIZE); |
1240 | 1282 |
break; |
1241 | 1283 |
|
Formats disponibles : Unified diff
Another shot at fixing the entrystats and entryzero stats