Re: git: 44aae623ab85 - main - Add ETHER_ALIGN support to ng_device(4).

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Mon, 15 Nov 2021 03:37:45 UTC
  Hi,

On Sun, Nov 14, 2021 at 12:39:21PM +0000, Emmanuel Vadot wrote:
E> Author:     Ian Lepore <ian@FreeBSD.org>
E> AuthorDate: 2021-11-09 14:34:06 +0000
E> Commit:     Emmanuel Vadot <manu@FreeBSD.org>
E> CommitDate: 2021-11-14 12:37:41 +0000
E> 
E>     Add ETHER_ALIGN support to ng_device(4).
E>     
E>     This adds a new ng_device command, NGM_DEVICE_ETHERALIGN, which has no
E>     associated args.  After the command arrives, the device begins adjusting all
E>     packets sent out its hook to have ETHER_ALIGN bytes of padding at the
E>     beginning of the packet.  The ETHER_ALIGN padding is added only when
E>     running on an architecture that requires strict alignment of IP headers
E>     (based on the __NO_STRICT_ALIGNMENT macro, which is only #define'd on
E>     x86 as of this writing).
E>     
E>     This also adds ascii <-> binary command translation to ng_device, both for
E>     the existing NGM_DEVICE_GET_DEVNAME and the new ETHERALIGN command.
E>     
E>     This also gives a name to every ng_device node when it is constructed, using
E>     the cdev device name (ngd0, ngd1, etc).  This makes it easier to address
E>     command msgs to the device using ngctl(8).

Since early days of netgraph there were plans to make data link types
on hooks. For example, for ng_ether or ng_eiface that would be hardcoded
to Ethernet. Other more generic nodes like ng_socket or ng_device would
be able to see peer's DLT and make their own decisions on that. Or even
netgraph itself would be able to enforce alignment. Hopefully some day
somebody will find time for that.

P.S. Also very curios to hear how ng_device is used in practice. I always
looked at it as at a test/experiment node type.

-- 
Gleb Smirnoff