Bug 213452 - [patch] [ipfw] add support for ipfw ngtee/netgraph actions at layer-2
Summary: [patch] [ipfw] add support for ipfw ngtee/netgraph actions at layer-2
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Eugene Grosbein
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-10-13 15:40 UTC by Eugene Grosbein
Modified: 2018-11-26 11:38 UTC (History)
3 users (show)

See Also:
eugen: mfc-stable12+
eugen: mfc-stable11+
eugen: mfc-stable10-


Attachments
add support for ngtee/netgraph ipfw actions for layer-2 frames (1.32 KB, patch)
2016-10-13 15:40 UTC, Eugene Grosbein
no flags Details | Diff
add support for ngtee/netgraph ipfw actions for layer-2 frames (1.39 KB, patch)
2017-03-04 17:26 UTC, Eugene Grosbein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2016-10-13 15:40:40 UTC
Created attachment 175712 [details]
add support for ngtee/netgraph ipfw actions for layer-2 frames

Currently, kernel part of ipfw for layer-2 (ethernet frames) does not support
and ignores ipfw rules other than "pass", "deny" and dummynet-related.
Any other rule acts like "pass" for layer-2 packets. That prevents us from
selective copying of Ethernet frames for remote traffic analyzing/mirroring 
purposes.

Assume, we have ethernet-like interface (NIC, vlan, tap etc.) and we need
to selectively mirror some frames there. In case of vlan900 and assuming ng_ipfw(4) netgraph node has a hook named "900" attached to "lower" hook
of vlan900's ng_ether(4) node, that would be as simple as:

ipfw add ngtee 900 ip from any to 8.8.8.8 layer2 out xmit igb0

Attached patch makes it work.
Comment 1 Eugene Grosbein 2017-03-04 17:26:47 UTC
Created attachment 180505 [details]
add support for ngtee/netgraph ipfw actions for layer-2 frames

Patch updated for recent 11-STABLE.
Comment 2 Eugene Grosbein freebsd_committer freebsd_triage 2017-09-19 17:23:46 UTC
My PR.
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-10-27 07:32:48 UTC
A commit references this bug:

Author: eugen
Date: Sat Oct 27 07:32:26 UTC 2018
New revision: 339810
URL: https://svnweb.freebsd.org/changeset/base/339810

Log:
  ipfw: implement ngtee/netgraph actions for layer-2 frames.

  Kernel part of ipfw does not support and ignores rules other than
  "pass", "deny" and dummynet-related for layer-2 (ethernet frames).
  Others are processed as "pass".

  Make it support ngtee/netgraph rules just like they are supported
  for IP packets. For example, this allows us to mirror some frames
  selectively to another interface for delivery to remote network analyzer
  over RSPAN vlan. Assuming ng_ipfw(4) netgraph node has a hook named "900"
  attached to "lower" hook of vlan900's ng_ether(4) node, that would be
  as simple as:

  ipfw add ngtee 900 ip from any to 8.8.8.8 layer2 out xmit igb0

  PR:		213452
  MFC after:	1 month
  Tested-by:	Fyodor Ustinov <ufm@ufm.su>

Changes:
  head/sys/netpfil/ipfw/ip_fw_pfil.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-11-26 11:29:14 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 26 11:28:35 UTC 2018
New revision: 340955
URL: https://svnweb.freebsd.org/changeset/base/340955

Log:
  MFC r339810: ipfw: implement ngtee/netgraph actions for layer-2 frames.

    Kernel part of ipfw does not support and ignores rules other than
    "pass", "deny" and dummynet-related for layer-2 (ethernet frames).
    Others are processed as "pass".

    Make it support ngtee/netgraph rules just like they are supported
    for IP packets. For example, this allows us to mirror some frames
    selectively to another interface for delivery to remote network analyzer
    over RSPAN vlan. Assuming ng_ipfw(4) netgraph node has a hook named "900"
    attached to "lower" hook of vlan900's ng_ether(4) node, that would be
    as simple as:

    ipfw add ngtee 900 ip from any to 8.8.8.8 layer2 out xmit igb0

  PR:		213452
  Tested-by:	Fyodor Ustinov <ufm@ufm.su>

Changes:
_U  stable/12/
  stable/12/sys/netpfil/ipfw/ip_fw_pfil.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-11-26 11:33:19 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 26 11:32:22 UTC 2018
New revision: 340956
URL: https://svnweb.freebsd.org/changeset/base/340956

Log:
  MFC r339810: ipfw: implement ngtee/netgraph actions for layer-2 frames.

    Kernel part of ipfw does not support and ignores rules other than
    "pass", "deny" and dummynet-related for layer-2 (ethernet frames).
    Others are processed as "pass".

    Make it support ngtee/netgraph rules just like they are supported
    for IP packets. For example, this allows us to mirror some frames
    selectively to another interface for delivery to remote network analyzer
    over RSPAN vlan. Assuming ng_ipfw(4) netgraph node has a hook named "900"
    attached to "lower" hook of vlan900's ng_ether(4) node, that would be
    as simple as:

    ipfw add ngtee 900 ip from any to 8.8.8.8 layer2 out xmit igb0

  PR:		213452
  Tested-by:	Fyodor Ustinov <ufm@ufm.su>

Changes:
_U  stable/11/
  stable/11/sys/netpfil/ipfw/ip_fw_pfil.c