Re: new mbuf flag proposal
- From: Tom Judge <tom@xxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 22:32:52 +0100
Oleg Bulyzhin wrote:
Hi all.
Recently, i discovered following problem (though it was already discussed, see
http://freebsd.rambler.ru/bsdmail/freebsd-ipfw_2006/msg00491.html):
pfil handlers (like ipfw or pf) sometime need to create packets (like tcp rst
or icmp errors). In order to avoid loops M_SKIP_FIREWALL flag is used.
Unfortunately, this behaviour is not always correct.
There are configurations when you need to reinject such packets into pfil(4)
handlers (in order to translate them using NAT or apply routing policy or divert them somewhere, etc). In my case i had to modify kernel
in order to translate tcp keepalive packets(generated by ipfw) using pfnat.
I have a proposal how to solve this:
1) Introduce new mbuf flag, something like M_PFIL_CREATED, which should be
used to mark packets created by pfil handler. If packet is not supposed
to reenter pfil handlers M_SKIP_FIREWALL can be used instead.
2) When pfil handler generate packet it should be marked either with
M_SKIP_FIREWALL or M_PFIL_CREATED. In latter case, pfil handler should add
mbuf_tag for distinguishing source of M_PFIL_CREATED flag.
I only really have one comment, surely all packets created in pfil handlers should have M_PFIL_CREATED set, and those that should not pass through the firewall should have M_SKIP_FIREWALL set in addition?
Just my 2p
Tom
So, for packet creation code should be like this:
m->m_flags |= M_PFIL_CREATED;
mtag = m_tag_alloc(MTAG_PFIL_CREATED, PFIL_IPFW, 0, M_NOWAIT);
if (mtag) {
m_tag_prepend(m, mtag);
} else {
goto drop_pkt;
}
at the beginning of pfil handler we should have something like this:
int dont_emit_pkt = 0;
if (m->m_flags & M_PFIL_CREATED) {
dont_emit_pkt = 1;
mtag = m_tag_locate(m, MTAG_PFIL_CREATED, PFIL_IPFW, NULL);
if (mtag) { /* pkt was created by myself */
/* my own packet, handle it with care. */
goto specal_handler;
} else { /* pkt was created by other pfil(4) handler */
/* do normal processing but do not emit new packets. */
goto normal_handler;
}
}
This functionality can be archived with mbuf_tag only (without new mbuf flag),
but it would be ineffective:
calling m_tag_locate() (unsuccessful most of the time!) for every packet is
rather expensive.
What do you think about this?
_______________________________________________
freebsd-net@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@xxxxxxxxxxx"
- References:
- new mbuf flag proposal
- From: Oleg Bulyzhin
- new mbuf flag proposal
- Prev by Date: libpcap/tcpdump update
- Previous by thread: Re: new mbuf flag proposal
- Next by thread: Re: bin/116643: [patch] fstat(1): add INET/INET6 socket details as in NetBSD and OpenBSD
- Index(es):
Relevant Pages
- Ambiguities in TCP/IP - firewall bypassing
... There are ambiguities in implementations of the TCP/IP suite for various ...
oriented communication using the TCP protocol. ... or something called 'Christmas packet'
having mostly every TCP flag set ... Also SYN,FIN packets works well... ...
(Bugtraq) - [TOOL] TunnelShell, Tunneling Shell Access via TCP/UDP/Fraged/ICMP/RawIP Packets
... Using IPv4 fragmented packets to encapsulate data. ... even if they have a rule
to deny it (You could select layer ... It does not bind to any port, so you can
use a port already ... you can specify a layer four protocol with flag -o. ... (Securiteam) - Re: Network performance in a dual CPU system
... M>>forwarding ... M>>any packet filters or other additional processing
of forwarded packets? ... Virtual interface disc0 is our ... packet if it
is routed to interface w/o IFF_DRV_RUNNING flag. ... (freebsd-net) - Re: 2.6.16-rc4 bridge/iptables Oops
... When these packets are SNATed and a policy ... Change xfrm_lookup not to dereference
dst->ops before checking for the ... DST_NOXFRM flag and set this flag in the fake dst_entry.
... (Linux-Kernel) - Bits How to program them
... I am writing a P2P client application. ... are to be sent between the peers.
... of the packets may be programmed. ... message type, 1 for the start flag,
1 for the body, and 1 for the end flag. ... (comp.lang.c)