Page MenuHomeFreeBSD

D40866.id124147.diff
No OneTemporary

D40866.id124147.diff

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -517,6 +517,22 @@
m_copyback(m, off, sizeof(*uh), (caddr_t)uh);
break;
}
+ case IPPROTO_SCTP: {
+ struct sctphdr *sh = &pd->hdr.sctp;
+ uint16_t checksum = 0;
+
+ if (PF_ANEQ(pd->src, &nk->addr[pd->sidx], pd->af))
+ pf_change_ap(m, pd->src, &sh->src_port, pd->ip_sum,
+ &checksum, &nk->addr[pd->sidx],
+ nk->port[pd->sidx], 1, pd->af);
+ if (PF_ANEQ(pd->dst, &nk->addr[pd->didx], pd->af))
+ pf_change_ap(m, pd->dst, &sh->dest_port, pd->ip_sum,
+ &checksum, &nk->addr[pd->didx],
+ nk->port[pd->didx], 1, pd->af);
+ m->m_pkthdr.csum_flags &= ~CSUM_SCTP;
+ m_copyback(m, off, sizeof(*sh), (caddr_t)sh);
+ break;
+ }
case IPPROTO_ICMP: {
struct icmp *ih = &pd->hdr.icmp;
@@ -4453,6 +4469,37 @@
}
rewrite++;
break;
+ case IPPROTO_SCTP: {
+ uint16_t checksum = 0;
+
+ if (PF_ANEQ(saddr, &nk->addr[pd->sidx], af) ||
+ nk->port[pd->sidx] != sport) {
+ pf_change_ap(m, saddr, &pd->hdr.sctp.src_port,
+ pd->ip_sum, &checksum,
+ &nk->addr[pd->sidx],
+ nk->port[pd->sidx], 1, af);
+ sport = pd->hdr.sctp.src_port;
+ pd->sport = &pd->hdr.sctp.src_port;
+ }
+ if (PF_ANEQ(daddr, &nk->addr[pd->didx], af) ||
+ nk->port[pd->didx] != dport) {
+ pf_change_ap(m, daddr, &pd->hdr.sctp.dest_port,
+ pd->ip_sum, &checksum,
+ &nk->addr[pd->didx],
+ nk->port[pd->didx], 1, af);
+ dport = pd->hdr.sctp.dest_port;
+ pd->dport = &pd->hdr.sctp.dest_port;
+ }
+
+ /* We can't do an incremental update, because
+ * it's CRC32 and we may do futher
+ * modifications later, so let the output path
+ * recompute the checksum. */
+ m->m_pkthdr.csum_flags &= ~CSUM_SCTP;
+
+ rewrite++;
+ break;
+ }
#ifdef INET
case IPPROTO_ICMP:
nk->port[0] = nk->port[1];
@@ -5847,6 +5894,29 @@
(*state)->expire = time_uptime;
+ /* translate source/destination address, if necessary */
+ if ((*state)->key[PF_SK_WIRE] != (*state)->key[PF_SK_STACK]) {
+ uint16_t checksum = 0;
+ struct pf_state_key *nk = (*state)->key[pd->didx];
+
+ if (PF_ANEQ(pd->src, &nk->addr[pd->sidx], pd->af) ||
+ nk->port[pd->sidx] != pd->hdr.sctp.src_port)
+ pf_change_ap(m, pd->src, &pd->hdr.sctp.src_port,
+ pd->ip_sum, &checksum, &nk->addr[pd->sidx],
+ nk->port[pd->sidx], 1, pd->af);
+
+ if (PF_ANEQ(pd->dst, &nk->addr[pd->didx], pd->af) ||
+ nk->port[pd->didx] != pd->hdr.sctp.dest_port)
+ pf_change_ap(m, pd->dst, &pd->hdr.sctp.dest_port,
+ pd->ip_sum, &checksum, &nk->addr[pd->didx],
+ nk->port[pd->didx], 1, pd->af);
+
+ /* Force checksum recalculation. */
+ m->m_pkthdr.csum_flags &= ~CSUM_SCTP;
+
+ m_copyback(m, off, sizeof(pd->hdr.sctp), (caddr_t)&pd->hdr.sctp);
+ }
+
return (PF_PASS);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 24, 6:46 PM (5 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16097193
Default Alt Text
D40866.id124147.diff (2 KB)

Event Timeline