{"id":3835,"date":"2022-12-20T17:20:13","date_gmt":"2022-12-20T20:20:13","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/ematch-man8\/"},"modified":"2022-12-20T17:20:13","modified_gmt":"2022-12-20T20:20:13","slug":"ematch-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/ematch-man8\/","title":{"rendered":"ematch (man8)"},"content":{"rendered":"<h1 align=\"center\">ematch<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#MATCHES\">MATCHES<\/a><br \/> <a href=\"#CAVEATS\">CAVEATS<\/a><br \/> <a href=\"#EXAMPLE &#038; USAGE\">EXAMPLE &#038; USAGE<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">ematch \u2212 extended matches for use with &#8220;basic&#8221;, &#8220;cgroup&#8221; or &#8220;flow&#8221; filters<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc filter add .. basic match<\/b> EXPR <b>.. flowid ..<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>EXPR<\/i> := <i>TERM<\/i> [ { <b>and | or<\/b> } <i>EXPR<\/i> ]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>TERM<\/i> := [ <b>not<\/b> ] { <i>MATCH<\/i> | \u2019(\u2019 <i>EXPR<\/i> \u2019)\u2019 }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>MATCH<\/i> := <i>module<\/i> \u2019(\u2019 <i>ARGS<\/i> \u2019)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ARGS<\/i> := <i>ARG1 ARG2<\/i> ..<\/p>\n<h2>MATCHES <a name=\"MATCHES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>cmp<\/b> <br \/> Simple comparison ematch: arithmetic compare of packet data to a given value.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>cmp<\/i>( <i>ALIGN<\/i> at <i>OFFSET<\/i> [ <i>ATTRS<\/i> ] { <i>eq<\/i> | <i>lt<\/i> | <i>gt<\/i> } <i>VALUE<\/i> )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ALIGN<\/i> := { <i>u8<\/i> | <i>u16<\/i> | <i>u32<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ATTRS<\/i> := [ layer <i>LAYER<\/i> ] [ mask <i>MASK<\/i> ] [ trans ]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>LAYER<\/i> := { <i>link<\/i> | <i>network<\/i> | <i>transport<\/i> | <i>0..2<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>meta<\/b> <br \/> Metadata ematch<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>meta<\/i>( <i>OBJECT<\/i> { <i>eq<\/i> | <i>lt<\/i> |<i>gt<\/i> } <i>OBJECT<\/i> )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>OBJECT<\/i> := { <i>META_ID<\/i> | <i>VALUE<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>META_ID<\/i> := <i>id<\/i> [ shift <i>SHIFT<\/i> ] [ mask <i>MASK<\/i> ] <br \/> meta attributes:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>random<\/b> 32 bit random value<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>loadavg_1<\/b> Load average in last 5 minutes<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>nf_mark<\/b> Netfilter mark<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>vlan<\/b> Vlan tag<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>sk_rcvbuf<\/b> Receive buffer size<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>sk_snd_queue<\/b> Send queue length<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A full list of meta attributes can be obtained via<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># tc filter add dev eth1 basic match \u2019meta(list)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>nbyte<\/b> <br \/> match packet data byte sequence<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>nbyte<\/i>( <i>NEEDLE<\/i> at <i>OFFSET<\/i> [ layer <i>LAYER<\/i> ] )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>NEEDLE<\/i> := { <i>string<\/i> | <i>c-escape-sequence<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>OFFSET<\/i> := <i>int<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>LAYER<\/i> := { <i>link<\/i> | <i>network<\/i> | <i>transport<\/i> | <i>0..2<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>u32<\/b> <br \/> u32 ematch<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>u32<\/i>( <i>ALIGN VALUE MASK<\/i> at [ nexthdr+ ] <i>OFFSET<\/i> )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ALIGN<\/i> := { <i>u8<\/i> | <i>u16<\/i> | <i>u32<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>ipset<\/b> <br \/> test packet against ipset membership<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ipset<\/i>( <i>SETNAME FLAGS<\/i> )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>SETNAME<\/i> := <i>string<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>FLAGS<\/i> := { <i>FLAG<\/i> [, <i>FLAGS<\/i>] }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The flag options are the same as those used by the iptables &#8220;set&#8221; match.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When using the ipset ematch with the &#8220;ip_set_hash:net,iface&#8221; set type, the interface can be queried using &#8220;src,dst (source ip address, outgoing interface) or &#8220;src,src&#8221; (source ip address, incoming interface) syntax.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>ipt<\/b> <br \/> test packet against xtables matches<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ipt<\/i>( <i>[-6] -m MATCH_NAME FLAGS<\/i> )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>MATCH_NAME<\/i> := <i>string<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>FLAGS<\/i> := { <i>FLAG<\/i> [, <i>FLAGS<\/i>] }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The flag options are the same as those used by the xtable match used.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>canid<\/b> <br \/> ematch rule to match CAN frames<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>canid<\/i>( <i>IDLIST<\/i> )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>IDLIST<\/i> := <i>IDSPEC<\/i>[<i>IDLIST<\/i>]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>IDSPEC<\/i> := { \u00e2sff\u00e2 <i>CANID<\/i> | \u00e2eff\u00e2 <i>CANID<\/i> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>CANID<\/i> := <i>ID<\/i>[<i>:MASK<\/i>]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ID<\/i>, <i>MASK<\/i> := hexadecimal number (i.e. 0x123)<\/p>\n<h2>CAVEATS <a name=\"CAVEATS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The ematch syntax uses \u2019(\u2019 and \u2019)\u2019 to group expressions. All braces need to be escaped properly to prevent shell commandline from interpreting these directly.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When using the ipset ematch with the &#8220;ifb&#8221; device, the outgoing device will be the ifb device itself, e.g. &#8220;ifb0&#8221;. The original interface (i.e. the device the packet arrived on) is treated as the incoming interface.<\/p>\n<h2>EXAMPLE &#038; USAGE <a name=\"EXAMPLE &#038; USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"># tc filter add .. basic match &#8230;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019cmp(u16 at 3 layer 2 mask 0xff00 gt 20)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019meta(nfmark gt 24)\u2019 and \u2019meta(tcindex mask 0xf0 eq 0xf0)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019nbyte(&#8220;ababa&#8221; at 12 layer 1)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019u32(u16 0x1122 0xffff at nexthdr+4)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Check if packet source ip address is member of set named <b>bulk<\/b>:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019ipset(bulk src)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Check if packet source ip and the interface the packet arrived on is member of &#8220;hash:net,iface&#8221; set named <b>interactive<\/b>:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019ipset(interactive src,src)\u2019<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Check if packet matches an IPSec state with reqid 1:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># \u2019ipt(-m policy &#8211;dir in &#8211;pol ipsec &#8211;reqid 1)\u2019<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The extended match infrastructure was added by Thomas Graf.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  ematch \u2212 extended matches for use with &#8220;basic&#8221;, &#8220;cgroup&#8221; or &#8220;flow&#8221; filters <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,931],"class_list":["post-3835","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-ematch"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3835"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3835\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}