isisd: pfpacket BPF filter with IS-IS over tunnel support

Signed-off-by: Josef Miegl <josef@miegl.cz>
This commit is contained in:
Josef Miegl 2023-03-12 16:15:27 +01:00
parent 8e09dce6bf
commit a0956b9522

View File

@ -35,14 +35,25 @@
/* tcpdump -i eth0 'isis' -dd */ /* tcpdump -i eth0 'isis' -dd */
static const struct sock_filter isisfilter[] = { static const struct sock_filter isisfilter[] = {
/* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped /* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped
* off! * off! */
* (OTOH it's a bit more lower-layer agnostic and might work /* The following BPF filter accepts IS-IS over LLC and IS-IS over
* over GRE?) */ * ethertype 0x00fe.
/* { 0x28, 0, 0, 0x0000000c - 14 }, */ * BPF assembly:
/* { 0x25, 5, 0, 0x000005dc }, */ * l0: ldh [0]
{0x28, 0, 0, 0x0000000e - 14}, {0x15, 0, 3, 0x0000fefe}, * l1: jeq #0xfefe, l2, l4
{0x30, 0, 0, 0x00000011 - 14}, {0x15, 0, 1, 0x00000083}, * l2: ldb [3]
{0x6, 0, 0, 0x00040000}, {0x6, 0, 0, 0x00000000}, * l3: jmp l7
* l4: ldh proto
* l5: jeq #0x00fe, l6, l9
* l6: ldb [0]
* l7: jeq #0x83, l8, l9
* l8: ret #0x40000
* l9: ret #0 */
{0x28, 0, 0, 0000000000}, {0x15, 0, 2, 0x0000fefe},
{0x30, 0, 0, 0x00000003}, {0x05, 0, 0, 0x00000003},
{0x28, 0, 0, 0xfffff000}, {0x15, 0, 3, 0x000000fe},
{0x30, 0, 0, 0000000000}, {0x15, 0, 1, 0x00000083},
{0x06, 0, 0, 0x00040000}, {0x06, 0, 0, 0000000000},
}; };
static const struct sock_fprog bpf = { static const struct sock_fprog bpf = {