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

Collapse All | Expand All

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

Return to bug 238796