diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2015-11-10 13:25:19 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-11-10 13:07:37 +0100 |
commit | 05787035b78755ad650c1fd69e68a5c28cf66602 (patch) | |
tree | 3fba45c5f4c93382432814e4298212e5e20ff714 /bpfc.8 | |
parent | 642906d31fccd6242b381fc1374de6035d7fbd4e (diff) |
bpfc: man: Add example how to filter rtnetlink by attributes
Example shows how to filter rtnetlink messages by ifindex & oper state.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'bpfc.8')
-rw-r--r-- | bpfc.8 | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -305,6 +305,30 @@ words, some small example filter programs: ret #-1 drop: ret #0 .PP +.SS Filter rtnetlink messages +.PP + ldh #proto /* A = skb->protocol */ + + jneq #0, skip /* check for NETLINK_ROUTE */ + ldb [4] /* A = nlmsg_type */ + + jneq #0x10, skip /* check type == RTNL_NEWLINK */ + ldx #16 /* X = offset(ifinfomsg) */ + + ldb [x + 4] /* offset(ifi_index) */ + jneq #0x3, skip /* check ifindex == 3 */ + + ld #32 /* A = len(nlmsghdr) + len(ifinfomsg), payload offset */ + ldx #16 /* X = IFLA_OPERSTATE */ + ld #nla /* A = offset(IFLA_OPERSTATE) */ + jeq #0, skip + tax + ldb [x + 4] /* A = value(IFLA_OPERSTATE) */ + jneq #0x6, skip /* check oper state is UP */ + + ret #-1 + skip: ret #0 +.PP .SH USAGE EXAMPLE .PP .SS bpfc fubar |