FreeBSD/sys/netpfil/pf/if_pfsync.c
/* Update an in-kernel tdb. Silently fail if no tdb is found. */
Update an in-kernel tdb. Silently fail if no tdb is found.
Update an in - kernel tdb . Silently fail if no tdb is found .
static void
pfsync_update_net_tdb(struct pfsync_tdb *pt)
{
	struct tdb		*tdb;
	int			 s;
	if (ntohl(pt->spi) <= SPI_RESERVED_MAX ||
	    (pt->dst.sa.sa_family != AF_INET &&
	    pt->dst.sa.sa_family != AF_INET6))
		goto bad;
	tdb = gettdb(pt->spi, &pt->dst, pt->sproto);
	if (tdb) {
		pt->rpl = ntohl(pt->rpl);
		pt->cur_bytes = (unsigned long long)be64toh(pt->cur_bytes);
		if (pt->rpl < tdb->tdb_rpl ||
		    pt->cur_bytes < tdb->tdb_cur_bytes) {
			goto bad;
		}
		tdb->tdb_rpl = pt->rpl;
		tdb->tdb_cur_bytes = pt->cur_bytes;
	}
	return;
bad:
	if (V_pf_status.debug >= PF_DEBUG_MISC)
		printf("pfsync_insert: PFSYNC_ACT_TDB_UPD: "
		    "invalid value\n");
	V_pfsyncstats.pfsyncs_badstate++;
	return;
}
static void pfsync_update_net_tdb ( struct pfsync_tdb * pt ) { struct tdb * tdb ; int s ; if ( ntohl ( pt -> spi ) <= SPI_RESERVED_MAX || ( pt -> dst . sa . sa_family != AF_INET && pt -> dst . sa . sa_family != AF_INET6 ) ) goto bad ; tdb = gettdb ( pt -> spi , & pt -> dst , pt -> sproto ) ; if ( tdb ) { pt -> rpl = ntohl ( pt -> rpl ) ; pt -> cur_bytes = ( unsigned long long ) be64toh ( pt -> cur_bytes ) ; if ( pt -> rpl < tdb -> tdb_rpl || pt -> cur_bytes < tdb -> tdb_cur_bytes ) { goto bad ; } tdb -> tdb_rpl = pt -> rpl ; tdb -> tdb_cur_bytes = pt -> cur_bytes ; } return ; bad : if ( V_pf_status . debug >= PF_DEBUG_MISC ) printf ( " " " \n " ) ; V_pfsyncstats . pfsyncs_badstate ++ ; return ; }
Update an in-kernel tdb.
Update an in - kernel tdb .
/* check for invalid values */ /* Neither replay nor byte counter should ever decrease. */