Projet

Général

Profil

« Précédent | Suivant » 

Révision 54a3971d

Ajouté par Ermal il y a presque 10 ans

Properly report statistics to the GUI

Voir les différences:

patches/stable/10/CP_speedup.diff
1 1
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
2
index 577d644..83207c5 100644
2
index 577d644..9bb11c3 100644
3 3
--- a/sbin/ipfw/ipfw2.c
4 4
+++ b/sbin/ipfw/ipfw2.c
5 5
@@ -4115,8 +4115,9 @@ ipfw_flush(int force)
......
200 200
+
201 201
+		if ((xent->flags & IPFW_TCF_INET) != 0) {
202 202
+			/* IPv4 address */
203
+			inet_ntop(AF_INET, &addr6->s6_addr32[3], tbuf, sizeof(tbuf));
203
+			inet_ntop(AF_INET, (in_addr_t *)addr6, tbuf, sizeof(tbuf));
204 204
+		} else {
205 205
+			/* IPv6 address */
206 206
+			inet_ntop(AF_INET6, addr6, tbuf, sizeof(tbuf));
......
697 697
     uint8_t plen, uint8_t mlen, uint8_t type);
698 698
 int ipfw_count_table(struct ip_fw_chain *ch, uint32_t tbl, uint32_t *cnt);
699 699
diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c
700
index cb9c89c..d98cac6 100644
700
index cb9c89c..ce9c330 100644
701 701
--- a/sys/netpfil/ipfw/ip_fw_sockopt.c
702 702
+++ b/sys/netpfil/ipfw/ip_fw_sockopt.c
703 703
@@ -1124,7 +1124,7 @@ ipfw_ctl(struct sockopt *sopt)
......
718 718
 				ipfw_del_table_entry(chain, xent->tbl, &xent->k,
719 719
 					len, xent->masklen, xent->type);
720 720
 		}
721
@@ -1245,6 +1245,47 @@ ipfw_ctl(struct sockopt *sopt)
721
@@ -1245,6 +1245,54 @@ ipfw_ctl(struct sockopt *sopt)
722 722
 		}
723 723
 		break;
724 724
 
......
739 739
+			}
740 740
+			
741 741
+			error = ipfw_zero_table_xentry_stats(chain, xent);
742
+			if (!error) {
743
+				xent->timestamp += boottime.tv_sec;
744
+				error = sooptcopyout(sopt, xent, sizeof(*xent));
745
+			}
742 746
+		}
743 747
+		break;
744 748
+
......
759 763
+			}
760 764
+			
761 765
+			error = ipfw_lookup_table_xentry(chain, xent);
762
+			xent->timestamp += boottime.tv_sec;
766
+			if (!error) {
767
+				xent->timestamp += boottime.tv_sec;
768
+				error = sooptcopyout(sopt, xent, sizeof(*xent));
769
+			}
763 770
+		}
764 771
+		break;
765 772
+
......
767 774
 		{
768 775
 			ipfw_xtable *tbl;
769 776
diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c
770
index 95cff5c..c1cf6f4 100644
777
index 95cff5c..3cb5242 100644
771 778
--- a/sys/netpfil/ipfw/ip_fw_table.c
772 779
+++ b/sys/netpfil/ipfw/ip_fw_table.c
773 780
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
......
1021 1028
+	xent->timestamp = time_uptime;
1022 1029
+}
1023 1030
+
1024
 int
1031
+int
1025 1032
+ipfw_zero_table_xentry_stats(struct ip_fw_chain *ch, ipfw_table_xentry *arg)
1026 1033
+{
1027 1034
+	struct radix_node_head *rnh;
......
1031 1038
+	struct xaddr_mix xm;
1032 1039
+
1033 1040
+	if (arg->tbl >= V_fw_tables_max)
1034
+		return (0);
1041
+		return (EINVAL);
1035 1042
+	if (ch->tables[arg->tbl] != NULL)
1036 1043
+		rnh = ch->tables[arg->tbl];
1037 1044
+	else if (ch->xtables[arg->tbl] != NULL)
1038 1045
+		rnh = ch->xtables[arg->tbl];
1039 1046
+	else
1040
+		return (0);
1047
+		return (EINVAL);
1041 1048
+
1042 1049
+	switch (arg->type) {
1043 1050
+	case IPFW_TABLE_CIDR:
......
1050 1057
+			sa.sin_addr.s_addr = *((in_addr_t *)&arg->k.addr6);
1051 1058
+			ent = (struct table_entry *)(rnh->rnh_lookup(&sa, NULL, rnh));
1052 1059
+			if (ent == NULL)
1053
+				return (0);
1060
+				return (EINVAL);
1054 1061
+
1055 1062
+			arg->bytes = 0;
1056 1063
+			arg->packets = 0;
1057 1064
+			arg->value = ent->value;
1058 1065
+			arg->timestamp = time_uptime;
1059 1066
+
1060
+			return (1);
1067
+			return (0);
1061 1068
+		} else {
1062 1069
+			KEY_LEN(sa6) = KEY_LEN_INET6;
1063 1070
+			memcpy(&sa6.sin6_addr, &arg->k.addr6, sizeof(struct in6_addr));
......
1093 1100
+		break;
1094 1101
+
1095 1102
+	default:
1096
+		return (0);
1103
+		return (EINVAL);
1097 1104
+	}
1098 1105
+
1099 1106
+	if (xent != NULL) {
......
1101 1108
+		xent->packets = 0;
1102 1109
+		xent->timestamp = time_uptime;
1103 1110
+		
1104
+		return (1);
1111
+		return (0);
1105 1112
+	}
1106
+	return (0);
1113
+	return (EINVAL);
1107 1114
+}
1108 1115
+
1109
+int
1116
 int
1110 1117
+ipfw_lookup_table_xentry(struct ip_fw_chain *ch, ipfw_table_xentry *arg)
1111 1118
+{
1112 1119
+	struct radix_node_head *rnh;
1113 1120
+	struct table_xentry *xent;
1114 1121
+
1115 1122
+	if (arg->tbl >= V_fw_tables_max)
1116
+		return (0);
1123
+		return (EINVAL);
1117 1124
+	if (ch->tables[arg->tbl] != NULL)
1118 1125
+		rnh = ch->tables[arg->tbl];
1119 1126
+	else if (ch->xtables[arg->tbl] != NULL)
1120 1127
+		rnh = ch->xtables[arg->tbl];
1121 1128
+	else
1122
+		return (0);
1129
+		return (EINVAL);
1123 1130
+
1124 1131
+	switch (arg->type) {
1125 1132
+	case IPFW_TABLE_CIDR:
......
1133 1140
+			sa.sin_addr.s_addr = *((in_addr_t *)&arg->k.addr6);
1134 1141
+			ent = (struct table_entry *)(rnh->rnh_lookup(&sa, NULL, rnh));
1135 1142
+			if (ent == NULL)
1136
+				return (0);
1143
+				return (EINVAL);
1137 1144
+
1138 1145
+			arg->bytes = ent->bytes;
1139 1146
+			arg->packets = ent->packets;
1140 1147
+			arg->value = ent->value;
1141 1148
+			arg->timestamp = ent->timestamp;
1142 1149
+			arg->mac_addr = ent->mac_addr;		
1143
+			return (1);
1150
+			return (0);
1144 1151
+		} else {
1145 1152
+			struct sockaddr_in6 sa6;
1146 1153
+			KEY_LEN(sa6) = KEY_LEN_INET6;
......
1196 1203
+		arg->timestamp = xent->timestamp;
1197 1204
+		arg->mac_addr = xent->mac_addr;
1198 1205
+		
1199
+		return (1);
1206
+		return (0);
1200 1207
+	}
1201
+	return (0);
1208
+	return (EINVAL);
1202 1209
+}
1203 1210
+
1204 1211
+void *

Formats disponibles : Unified diff