Lines Matching refs:sk

409 #define	STATE_ADDR_TRANSLATE(sk)					\
410 (sk)->lan.addr.addr32[0] != (sk)->gwy.addr.addr32[0] || \
411 ((sk)->af == AF_INET6 && \
412 ((sk)->lan.addr.addr32[1] != (sk)->gwy.addr.addr32[1] || \
413 (sk)->lan.addr.addr32[2] != (sk)->gwy.addr.addr32[2] || \
414 (sk)->lan.addr.addr32[3] != (sk)->gwy.addr.addr32[3]))
416 #define STATE_TRANSLATE(sk) \
417 (STATE_ADDR_TRANSLATE(sk) || \
418 (sk)->lan.xport.port != (sk)->gwy.xport.port)
420 #define STATE_GRE_TRANSLATE(sk) \
421 (STATE_ADDR_TRANSLATE(sk) || \
422 (sk)->lan.xport.call_id != (sk)->gwy.xport.call_id)
1112 struct pf_state_key *sk = NULL;
1119 sk = RB_FIND(pf_state_tree_lan_ext, &pf_statetbl_lan_ext,
1123 sk = RB_FIND(pf_state_tree_ext_gwy, &pf_statetbl_ext_gwy,
1131 if (sk != NULL)
1132 TAILQ_FOREACH(s, &sk->states, next)
1142 struct pf_state_key *sk = NULL;
1149 sk = RB_FIND(pf_state_tree_lan_ext,
1153 sk = RB_FIND(pf_state_tree_ext_gwy,
1160 if (sk != NULL) {
1161 ret = TAILQ_FIRST(&sk->states);
1165 TAILQ_FOREACH(s, &sk->states, next)
1261 struct pf_state_key *sk;
1266 sk = st->state_key;
1272 if (sk->af ==
1277 &sk->lan.addr, sk->af)) ||
1280 &sk->ext.addr, sk->af))) &&
1370 struct pf_state_key *sk = s->state_key;
1374 switch (sk->proto) {
1388 printf("PROTO=%u", sk->proto);
1392 pf_print_sk_host(&sk->lan, sk->af, sk->proto,
1393 sk->proto_variant);
1395 pf_print_sk_host(&sk->gwy, sk->af, sk->proto,
1396 sk->proto_variant);
1398 pf_print_sk_host(&sk->ext, sk->af, sk->proto,
1399 sk->proto_variant);
1432 /* must not happen. we must have found the sk above! */
1860 struct pf_state_key *sk = s->state_key;
1861 switch (sk->proto) {
1866 printf("GRE%u ", sk->proto_variant);
1881 printf("%u ", sk->proto);
1884 pf_print_sk_host(&sk->lan, sk->af, sk->proto, sk->proto_variant);
1886 pf_print_sk_host(&sk->gwy, sk->af, sk->proto, sk->proto_variant);
1888 pf_print_sk_host(&sk->ext, sk->af, sk->proto, sk->proto_variant);
2012 pf_calc_state_key_flowhash(struct pf_state_key *sk)
2017 if (PF_ALEQ(&sk->lan.addr, &sk->ext.addr, sk->af)) {
2018 bcopy(&sk->lan.addr, &fh.ap1.addr, sizeof (fh.ap1.addr));
2019 bcopy(&sk->ext.addr, &fh.ap2.addr, sizeof (fh.ap2.addr));
2021 bcopy(&sk->ext.addr, &fh.ap1.addr, sizeof (fh.ap1.addr));
2022 bcopy(&sk->lan.addr, &fh.ap2.addr, sizeof (fh.ap2.addr));
2024 if (sk->lan.xport.spi <= sk->ext.xport.spi) {
2025 fh.ap1.xport.spi = sk->lan.xport.spi;
2026 fh.ap2.xport.spi = sk->ext.xport.spi;
2028 fh.ap1.xport.spi = sk->ext.xport.spi;
2029 fh.ap2.xport.spi = sk->lan.xport.spi;
2031 fh.af = sk->af;
2032 fh.proto = sk->proto;
3208 struct pf_state_key *sk = s->state_key;
3209 if (!sk)
3213 if (sk->proto != IPPROTO_UDP || sk->af != af)
3215 if (sk->lan.xport.port != sxport->port)
3217 if (PF_ANEQ(&sk->lan.addr, saddr, af))
3220 PF_ANEQ(&sk->ext.addr, daddr, af))
3223 nxport->port = sk->gwy.xport.port;
3235 struct pf_state_key* sk = s->state_key;
3236 if (!sk)
3240 if (sk->proto != IPPROTO_TCP || sk->af != af)
3242 if (sk->lan.xport.port != sxport->port)
3244 if (!(PF_AEQ(&sk->lan.addr, saddr, af)))
3246 nxport->port = sk->gwy.xport.port;
3910 pf_attach_state(struct pf_state_key *sk, struct pf_state *s, int tail)
3912 s->state_key = sk;
3913 sk->refcnt++;
3917 TAILQ_INSERT_TAIL(&sk->states, s, next);
3919 TAILQ_INSERT_HEAD(&sk->states, s, next);
3925 struct pf_state_key *sk = s->state_key;
3927 if (sk == NULL)
3931 TAILQ_REMOVE(&sk->states, s, next);
3932 if (--sk->refcnt == 0) {
3935 &pf_statetbl_ext_gwy, sk);
3938 &pf_statetbl_lan_ext, sk);
3939 if (sk->app_state)
3940 pool_put(&pf_app_state_pl, sk->app_state);
3941 pool_put(&pf_state_key_pl, sk);
3948 struct pf_state_key *sk;
3950 if ((sk = pool_get(&pf_state_key_pl, PR_WAITOK)) == NULL)
3952 bzero(sk, sizeof (*sk));
3953 TAILQ_INIT(&sk->states);
3954 pf_attach_state(sk, s, 0);
3958 bcopy(&psk->lan, &sk->lan, sizeof (sk->lan));
3959 bcopy(&psk->gwy, &sk->gwy, sizeof (sk->gwy));
3960 bcopy(&psk->ext, &sk->ext, sizeof (sk->ext));
3961 sk->af = psk->af;
3962 sk->proto = psk->proto;
3963 sk->direction = psk->direction;
3964 sk->proto_variant = psk->proto_variant;
3966 sk->flowhash = psk->flowhash;
3967 /* don't touch tree entries, states and refcnt on sk */
3970 return (sk);
4719 struct pf_state_key *sk = NULL;
4801 if (sk != NULL) {
4802 if (sk->app_state)
4804 sk->app_state);
4805 pool_put(&pf_state_key_pl, sk);
4922 if ((sk = pf_alloc_state_key(s, &psk)) == NULL) {
4931 if (sk->app_state == 0) {
4935 sk->ext.xport.port : sk->gwy.xport.port;
4954 sk->app_state = as;
4981 sk->app_state = as;
5037 if (sk->app_state && sk->app_state->handler) {
5053 sk->app_state->handler(s, direction, offx,
5462 struct pf_state_key *sk;
5466 sk = s->state_key;
5467 pptps = &sk->app_state->u.pptp;
5519 memcpy(&gsk->lan, &sk->lan, sizeof (gsk->lan));
5520 memcpy(&gsk->gwy, &sk->gwy, sizeof (gsk->gwy));
5521 memcpy(&gsk->ext, &sk->ext, sizeof (gsk->ext));
5522 gsk->af = sk->af;
5540 switch (sk->direction) {
5723 pf_set_rt_ifp(gs, &sk->lan.addr);
7265 struct pf_state_key *sk = s->state_key;
7268 &pf_statetbl_ext_gwy, sk);
7269 sk->lan.xport.spi = sk->gwy.xport.spi =
7273 &pf_statetbl_ext_gwy, sk))
7283 struct pf_state_key *sk = s->state_key;
7286 &pf_statetbl_lan_ext, sk);
7287 sk->ext.xport.spi = esp->spi;
7290 &pf_statetbl_lan_ext, sk))
8058 struct pf_state_key *sk = NULL;
8485 sk = s->state_key;
8498 dirndx = (dir == sk->direction) ? 0 : 1;
8513 x = (sk == NULL || sk->direction == dir) ?
8516 x = (sk == NULL || sk->direction == dir) ?
8527 pfr_update_stats(tr->src.addr.p.tbl, (sk == NULL ||
8528 sk->direction == dir) ?
8533 pfr_update_stats(tr->dst.addr.p.tbl, (sk == NULL ||
8534 sk->direction == dir) ? pd.dst : pd.src, pd.af,
8592 struct pf_state_key *sk = NULL;
9079 sk = s->state_key;
9092 dirndx = (dir == sk->direction) ? 0 : 1;
9107 x = (s == NULL || sk->direction == dir) ?
9110 x = (s == NULL || sk->direction == dir) ?
9121 pfr_update_stats(tr->src.addr.p.tbl, (sk == NULL ||
9122 sk->direction == dir) ? pd.src : pd.dst, pd.af,
9126 pfr_update_stats(tr->dst.addr.p.tbl, (sk == NULL ||
9127 sk->direction == dir) ? pd.dst : pd.src, pd.af,