ematch



ematch

NAME
SYNOPSIS
MATCHES
CAVEATS
EXAMPLE & USAGE
AUTHOR

NAME

ematch − extended matches for use with "basic" or "flow" filters

SYNOPSIS

tc filter add .. basic match EXPR .. flowid ..

EXPR := TERM [ { and | or } EXPR ]

TERM := [ not ] { MATCH | ’(’ EXPR ’)’ }

MATCH := module ’(’ ARGS ’)’

ARGS := ARG1 ARG2 ..

MATCHES

cmp
Simple comparison ematch: arithmetic compare of packet data to a given value.

cmp( ALIGN at OFFSET [ ATTRS ] { eq | lt | gt } VALUE )

ALIGN := { u8 | u16 | u32 }

ATTRS := [ layer LAYER ] [ mask MASK ] [ trans ]

LAYER := { link | network | transport | 0..2 }

meta
Metadata ematch

meta( OBJECT { eq | lt |gt } OBJECT )

OBJECT := { META_ID | VALUE }

META_ID := id [ shift SHIFT ] [ mask MASK ]
meta attributes:

random 32 bit random value

loadavg_1 Load average in last 5 minutes

nf_mark Netfilter mark

vlan Vlan tag

sk_rcvbuf Receive buffer size

sk_snd_queue Send queue length

A full list of meta attributes can be obtained via

# tc filter add dev eth1 basic match ’meta(list)’

nbyte
match packet data byte sequence

nbyte( NEEDLE at OFFSET [ layer LAYER ] )

NEEDLE := { string | c-escape-sequence }

OFFSET := int

LAYER := { link | network | transport | 0..2 }

u32
u32 ematch

u32( ALIGN VALUE MASK at [ nexthdr+ ] OFFSET )

ALIGN := { u8 | u16 | u32 }

ipset
test packet against ipset membership

ipset( SETNAME FLAGS )

SETNAME := string

FLAGS := { FLAG [, FLAGS] }

The flag options are the same as those used by the iptables "set" match.

When using the ipset ematch with the "ip_set_hash:net,iface" set type, the interface can be queried using "src,dst (source ip address, outgoing interface) or "src,src" (source ip address, incoming interface) syntax.

CAVEATS

The ematch syntax uses ’(’ and ’)’ to group expressions. All braces need to be escaped properly to prevent shell commandline from interpreting these directly.

When using the ipset ematch with the "ifb" device, the outgoing device will be the ifb device itself, e.g. "ifb0". The original interface (i.e. the device the packet arrived on) is treated as the incoming interface.

EXAMPLE & USAGE

# tc filter add .. basic match ...

# ’cmp(u16 at 3 layer 2 mask 0xff00 gt 20)’

# ’meta(nfmark gt 24)’ and ’meta(tcindex mask 0xf0 eq 0xf0)’

# ’nbyte("ababa" at 12 layer 1)’

# ’u32(u16 0x1122 0xffff at nexthdr+4)’

Check if packet source ip address is member of set named bulk:

# ’ipset(bulk src)’

Check if packet source ip and the interface the packet arrived on is member of "hash:net,iface" set named interactive:

# ’ipset(interactive src,src)’

AUTHOR

The extended match infrastructure was added by Thomas Graf.







Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.