View | Details | Raw Unified | Return to bug 238796 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/contrib/ipfilter/netinet/fil.c (-5 / +66 lines)
Lines 4411-4416 ipf_matchicmpqueryreply(v, ic, icmp, rev) Link Here
4411
	return 0;
4411
	return 0;
4412
}
4412
}
4413
4413
4414
static inline int
4415
ipf_ifnames_compare(const int *ifnames1, const int *ifnames2,
4416
	const char *base1, const char *base2)
4417
{
4418
	int i;
4419
4420
	for(i = 0; i < 4; i++) {
4421
		if ((ifnames1[i] != -1 && ifnames2[i] == -1) ||
4422
		   (ifnames1[i] == -1 && ifnames2[i] != -1) ||
4423
		   (ifnames1[i] == -1 && ifnames2[i] == -1 &&
4424
		    strcmp(base1 + ifnames1[i], base2 + ifnames2[i])))
4425
			return(1);
4426
	}
4427
	return(0);
4428
}
4429
4430
static inline int
4431
ipf_dest_compare(const frdest_t *d1, const frdest_t *d2,
4432
	const char *base1, const char *base2)
4433
{
4434
	if (d1->fd_addr != d2->fd_addr || d1->fd_type != d2->fd_type ||
4435
	   (d1->fd_name != -1 && d2->fd_name == -1) ||
4436
	   (d1->fd_name == -1 && d2->fd_name != -1) ||
4437
	   (d1->fd_name != -1 && d2->fd_name != -1 &&
4438
	    d1->fd_type == FRD_NORMAL &&
4439
	    strcmp(base1 + d1->fd_name, base2 + d2->fd_name)))
4440
		return(1);
4441
	return(0);
4442
}
4414
4443
4415
/* ------------------------------------------------------------------------ */
4444
/* ------------------------------------------------------------------------ */
4416
/* Function:    ipf_rule_compare                                            */
4445
/* Function:    ipf_rule_compare                                            */
Lines 4430-4437 ipf_rule_compare(frentry_t *fr1, frentry_t *fr2) Link Here
4430
		return 2;
4459
		return 2;
4431
	if (fr1->fr_dsize != fr2->fr_dsize)
4460
	if (fr1->fr_dsize != fr2->fr_dsize)
4432
		return 3;
4461
		return 3;
4433
	if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func,
4462
	if (memcmp(&fr1->fr_func, &fr2->fr_func,
4434
		 fr1->fr_size - offsetof(struct frentry, fr_func)) != 0)
4463
	    offsetof(struct frentry, fr_ifnames) -
4464
	    offsetof(struct frentry, fr_func)) != 0)
4465
		return 4;
4466
	if (ipf_ifnames_compare(fr1->fr_ifnames, fr2->fr_ifnames,
4467
	    fr1->fr_names, fr2->fr_names))
4468
		return 4;
4469
	if (memcmp(&fr1->fr_func, &fr2->fr_func,
4470
	    offsetof(struct frentry, fr_tifs) -
4471
	    offsetof(struct frentry, fr_isctag)) != 0)
4472
		return 4;
4473
	if (ipf_dest_compare(&fr1->fr_tifs[0], &fr2->fr_tifs[0],
4474
	    fr1->fr_names, fr2->fr_names))
4475
		return 4;
4476
	if (ipf_dest_compare(&fr1->fr_tifs[1], &fr2->fr_tifs[1],
4477
	    fr1->fr_names, fr2->fr_names))
4478
		return 4;
4479
	if (ipf_dest_compare(&fr1->fr_dif, &fr2->fr_dif,
4480
	    fr1->fr_names, fr2->fr_names))
4435
		return 4;
4481
		return 4;
4436
	if (fr1->fr_data && !fr2->fr_data)
4482
	if (fr1->fr_data && !fr2->fr_data)
4437
		return 5;
4483
		return 5;
Lines 4914-4924 frrequest(softc, unit, req, data, set, makecopy) Link Here
4914
	 * the constant part of the filter rule to make comparisons quicker
4960
	 * the constant part of the filter rule to make comparisons quicker
4915
	 * (this meaning no pointers are included).
4961
	 * (this meaning no pointers are included).
4916
	 */
4962
	 */
4917
	for (fp->fr_cksum = 0, p = (u_int *)&fp->fr_func, pp = &fp->fr_cksum;
4963
	fp->fr_cksum = 0;
4964
	for (p = (u_int *)&fp->fr_func, pp = (u_int *)fp->fr_ifnames;
4965
	     p < pp; p++)
4966
		fp->fr_cksum += *p;
4967
	for (p = (u_int *)&fp->fr_isctag, pp = (u_int *)fp->fr_tifs;
4918
	     p < pp; p++)
4968
	     p < pp; p++)
4919
		fp->fr_cksum += *p;
4969
		fp->fr_cksum += *p;
4920
	pp = (u_int *)(fp->fr_caddr + fp->fr_dsize);
4970
	{
4921
	for (p = (u_int *)fp->fr_data; p < pp; p++)
4971
		int i;
4972
		for (i = 0; i <= 1; i++)
4973
			for (p = (u_int *)&fp->fr_tifs[i].fd_addr,
4974
			     pp = (u_int *)&fp->fr_tifs[i].fd_name;
4975
				p < pp; p++)
4976
					fp->fr_cksum += *p;
4977
	}
4978
	for (p = (u_int *)&fp->fr_dif.fd_addr, pp = (u_int *)&fp->fr_dif.fd_name;
4979
	     p < pp; p++)
4980
		fp->fr_cksum += *p;
4981
	for (p = (u_int *)fp->fr_data, pp = (u_int *)(fp->fr_caddr + fp->fr_dsize);
4982
	     p < pp; p++)
4922
		fp->fr_cksum += *p;
4983
		fp->fr_cksum += *p;
4923
4984
4924
	WRITE_ENTER(&softc->ipf_mutex);
4985
	WRITE_ENTER(&softc->ipf_mutex);

Return to bug 238796