# IPFW divert on layer2 (bridged)



## draco003 (Mar 18, 2013)

Peace,

I'm working on adding support for *layer2* *diverts* in IPFW(8) for *FreeBSD 9.0* - I'm going through some patches submitted in 2006 that adds L2 diverts to IPFW(8), but it was coded for *6.x* I believe (by Julian Elischer). And it works on the old bridge.c which was retired as of *RELEASE-7.0* and was replaced with if_config.c

Max Laier from the mailing list suggested adding an L2-hook PFIL(9) inside ip_fw_pfil.c

I've also came across the patch for ip_fw2.c  (22 Sep 2003 by Luigi Rizzo) for handling *fwd* in *layer2* using tags approach and changes were made to _case O_FORWARD_IP_ opcode. Luigi also mentioned this could be adapted to allow layer2 diverts as well. I'm willing to code the patch and release it for *FreeBSD 9.0* or later.

There is also a couple of *PR*s I came across: 
PR kern/156770
PR kern/156279
PR kern/86957
PR kern/119744
PR kern/86957
Any suggestions or directions would be much appreciated. 
If someone is interested on the topic, or has info on similar patches that apply to *7.x**+* I would be grateful for sharing.

Thank you,
Draco


----------



## draco003 (Mar 21, 2013)

So I contacted some of guys on -IPFW and -net.

*Alter* was willing to help and he also got some very interesting patches to commit.
http://www2.alter.org.ua/en/soft/fbsd/ipfw/

*Gleb* was also very helpful and supplied this some old but helpful patch:
https://github.com/glk/l2filter/

I finished scanning the ip_fw2.c source code and I'm diving into ip_divert.c and pfil(9) functions.

I'm open to suggestions and if someone is interested to help.

Thanks.


----------



## sabri (Aug 2, 2013)

Hi Draco,

Any luck so far? I've been trying to manually patch 9.1 using those older patches but break the build every time...

Thanks,

Sabri


----------



## DutchDaemon (Aug 2, 2013)

Hey, welcome @sabri


----------

