{
    "mode": "man",
    "parameter": "tc-flow",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/tc-flow/8/json",
    "generated": "2026-06-15T13:13:05Z",
    "synopsis": "Mapping mode:\ntc filter ... flow map key KEY [ OPS ] [ OPTIONS ]\nHashing mode:\ntc filter ... flow hash keys KEYLIST [ perturb secs ] [ OPTIONS ]\nOPS := [ OPS ] OP\nOPTIONS := [ divisor NUM ] [ baseclass ID ] [ match EMATCHTREE ] [ action ACTIONSPEC ]\nKEYLIST := [ KEYLIST ] KEY\nOP := { or | and | xor | rshift | addend } NUM\nID := X:Y\nKEY  := { src | dst | proto | proto-src | proto-dst | iif | priority | mark | nfct | nfct-src\n| nfct-dst | nfct-proto-src | nfct-proto-dst | rt-classid | sk-uid | sk-gid  |  vlan-\ntag | rxhash }",
    "sections": {
        "NAME": {
            "content": "flow - flow based traffic control filter\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Mapping mode:\n\ntc filter ... flow map key KEY [ OPS ] [ OPTIONS ]\n\nHashing mode:\n\ntc filter ... flow hash keys KEYLIST [ perturb secs ] [ OPTIONS ]\n\nOPS := [ OPS ] OP\n\nOPTIONS := [ divisor NUM ] [ baseclass ID ] [ match EMATCHTREE ] [ action ACTIONSPEC ]\n\nKEYLIST := [ KEYLIST ] KEY\n\nOP := { or | and | xor | rshift | addend } NUM\n\nID := X:Y\n\nKEY  := { src | dst | proto | proto-src | proto-dst | iif | priority | mark | nfct | nfct-src\n| nfct-dst | nfct-proto-src | nfct-proto-dst | rt-classid | sk-uid | sk-gid  |  vlan-\ntag | rxhash }\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  flow  classifier is meant to extend the SFQ hashing capabilities without hard-coding new\nhash functions. It also allows deterministic mappings of keys to classes.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "action ACTIONSPEC\nApply an action from the generic actions framework on matching packets.\n\nbaseclass ID\nAn offset for the resulting class ID.  ID may be root, none or a hexadecimal class  ID\nin  the form [X:]Y. X must match qdisc's/class's major handle (if omitted, the correct\nvalue is chosen automatically). If the whole baseclass is omitted, Y defaults to 1.\n\ndivisor NUM\nNumber of buckets to use for sorting into. Keys are calculated modulo NUM.\n\nhash keys KEY-LIST\nPerform a jhash2 operation over the keys in KEY-LIST, the result (modulo  the  divisor\nif  given)  is  taken as class ID, optionally offset by the value of baseclass.  It is\npossible to specify an interval (in seconds) after which jhash2's  entropy  source  is\nrecreated using the perturb parameter.\n\nmap key KEY\nPacket  data  identified  by KEY is translated into class IDs to push the packet into.\nThe value may be mangled by OPS before using it for the mapping. They are  applied  in\nthe order listed here:\n\nand NUM\nPerform bitwise AND operation with numeric value NUM.\n\nor NUM\nPerform bitwise OR operation with numeric value NUM.\n\nxor NUM\nPerform bitwise XOR operation with numeric value NUM.\n\nrshift NUM\nShift the value of KEY to the right by NUM bits.\n\naddend NUM\nAdd NUM to the value of KEY.\n\nFor  the  or,  and, xor and rshift operations, NUM is assumed to be an unsigned, 32bit\ninteger value. For the addend operation, NUM may be much more complex: It may be  pre‐\nfixed  by  a minus ('-') sign to cause subtraction instead of addition and for keys of\nsrc, dst, nfct-src and nfct-dst it may be given in IP address notation. See below  for\nan illustrating example.\n\nmatch EMATCHTREE\nMatch packets using the extended match infrastructure. See tc-ematch(8) for a detailed\ndescription of the allowed syntax in EMATCHTREE.\n",
            "subsections": []
        },
        "KEYS": {
            "content": "In mapping mode, a single key is used (after optional permutation) to build a class  ID.  The\nresulting  ID  is deducible in most cases. In hashing more, a number of keys may be specified\nwhich are then hashed and the output used as class ID.  This ID is not deducible  in  before‐\nhand, and may even change over time for a given flow if a perturb interval has been given.\n\nThe range of class IDs can be limited by the divisor option, which is used for a modulus.\n\nsrc, dst\nUse source or destination address as key. In case of IPv4 and TIPC, this is the actual\naddress value. For IPv6, the 128bit address is folded into a 32bit  value  by  XOR'ing\nthe  four  32bit words. In all other cases, the kernel-internal socket address is used\n(after folding into 32bits on 64bit systems).\n\nproto  Use the layer four protocol number as key.\n",
            "subsections": [
                {
                    "name": "proto-src",
                    "content": "Use the layer four source port as key. If not available,  the  kernel-internal  socket\naddress is used instead.\n"
                },
                {
                    "name": "proto-dst",
                    "content": "Use  the  layer four destination port as key. If not available, the associated kernel-\ninternal dstentry address is used after XOR'ing with the packet's layer three  proto‐\ncol number.\n\niif    Use the incoming interface index as key.\n"
                },
                {
                    "name": "priority",
                    "content": "Use the packet's priority as key. Usually this is the IP header's DSCP/ECN value.\n\nmark   Use the netfilter fwmark as key.\n\nnfct   Use the associated conntrack entry address as key.\n\nnfct-src, nfct-dst, nfct-proto-src, nfct-proto-dst\nThese  are  conntrack-aware variants of src, dst, proto-src and proto-dst.  In case of\nNAT, these are basically the packet header's values before NAT was applied.\n"
                },
                {
                    "name": "rt-classid",
                    "content": "Use the packet's destination routing table entry's realm as key.\n"
                },
                {
                    "name": "sk-uid",
                    "content": "sk-gid For locally generated packets, use the user or group ID the originating socket belongs\nto as key.\n"
                },
                {
                    "name": "vlan-tag",
                    "content": "Use the packet's vlan ID as key.\n\nrxhash Use the flow hash as key.\n\n"
                }
            ]
        },
        "EXAMPLES": {
            "content": "Classic SFQ hash:\n\ntc filter add ... flow hash \\\nkeys src,dst,proto,proto-src,proto-dst divisor 1024\n\nClassic  SFQ  hash, but using information from conntrack to work properly in combination with\nNAT:\n\ntc filter add ... flow hash \\\nkeys nfct-src,nfct-dst,proto,nfct-proto-src,nfct-proto-dst \\\ndivisor 1024\n\nMap destination IPs of 192.168.0.0/24 to classids 1-256:\n\ntc filter add ... flow map \\\nkey dst addend -192.168.0.0 divisor 256\n\nAlternative to the above:\n\ntc filter add ... flow map \\\nkey dst and 0xff\n\nThe same, but in reverse order:\n\ntc filter add ... flow map \\\nkey dst and 0xff xor 0xff\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "tc(8), tc-ematch(8), tc-sfq(8)\n\n\n\niproute2                                     20 Oct 2015                        Flow filter in tc(8)",
            "subsections": []
        }
    },
    "summary": "flow - flow based traffic control filter",
    "flags": [],
    "examples": [
        "Classic SFQ hash:",
        "tc filter add ... flow hash \\",
        "keys src,dst,proto,proto-src,proto-dst divisor 1024",
        "Classic  SFQ  hash, but using information from conntrack to work properly in combination with",
        "NAT:",
        "tc filter add ... flow hash \\",
        "keys nfct-src,nfct-dst,proto,nfct-proto-src,nfct-proto-dst \\",
        "divisor 1024",
        "Map destination IPs of 192.168.0.0/24 to classids 1-256:",
        "tc filter add ... flow map \\",
        "key dst addend -192.168.0.0 divisor 256",
        "Alternative to the above:",
        "tc filter add ... flow map \\",
        "key dst and 0xff",
        "The same, but in reverse order:",
        "tc filter add ... flow map \\",
        "key dst and 0xff xor 0xff"
    ],
    "see_also": [
        {
            "name": "tc",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc/8/json"
        },
        {
            "name": "tc-ematch",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc-ematch/8/json"
        },
        {
            "name": "tc-sfq",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc-sfq/8/json"
        },
        {
            "name": "tc",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc/8/json"
        }
    ]
}