blob: 232df14e1287a3297716f0c16a0632194a189d50 [file] [log] [blame]
Greg Kroah-Hartman6f52b162017-11-01 15:08:43 +01001/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Thomas Graf14c0b972006-08-04 03:38:38 -07002#ifndef __LINUX_FIB_RULES_H
3#define __LINUX_FIB_RULES_H
4
5#include <linux/types.h>
6#include <linux/rtnetlink.h>
7
8/* rule is permanent, and cannot be deleted */
YOSHIFUJI Hideaki29f6af72007-04-06 11:45:39 -07009#define FIB_RULE_PERMANENT 0x00000001
10#define FIB_RULE_INVERT 0x00000002
11#define FIB_RULE_UNRESOLVED 0x00000004
Patrick McHardy491deb22009-12-03 01:25:54 +000012#define FIB_RULE_IIF_DETACHED 0x00000008
13#define FIB_RULE_DEV_DETACHED FIB_RULE_IIF_DETACHED
Patrick McHardy1b038a52009-12-03 01:25:56 +000014#define FIB_RULE_OIF_DETACHED 0x00000010
YOSHIFUJI Hideaki29f6af72007-04-06 11:45:39 -070015
16/* try to find source address in routing lookups */
17#define FIB_RULE_FIND_SADDR 0x00010000
Thomas Graf14c0b972006-08-04 03:38:38 -070018
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080019struct fib_rule_hdr {
Thomas Graf14c0b972006-08-04 03:38:38 -070020 __u8 family;
21 __u8 dst_len;
22 __u8 src_len;
23 __u8 tos;
24
25 __u8 table;
Donald Sharp1b71af62018-02-23 14:01:52 -050026 __u8 res1; /* reserved */
27 __u8 res2; /* reserved */
Thomas Graf14c0b972006-08-04 03:38:38 -070028 __u8 action;
29
30 __u32 flags;
31};
32
Lorenzo Colitti622ec2c2016-11-04 02:23:42 +090033struct fib_rule_uid_range {
34 __u32 start;
35 __u32 end;
36};
37
Roopa Prabhubfff4862018-02-28 22:40:16 -050038struct fib_rule_port_range {
39 __u16 start;
40 __u16 end;
41};
42
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080043enum {
Thomas Graf14c0b972006-08-04 03:38:38 -070044 FRA_UNSPEC,
45 FRA_DST, /* destination address */
46 FRA_SRC, /* source address */
Patrick McHardy491deb22009-12-03 01:25:54 +000047 FRA_IIFNAME, /* interface name */
48#define FRA_IFNAME FRA_IIFNAME
Thomas Graf0947c9fe2007-03-26 17:14:15 -070049 FRA_GOTO, /* target to jump to (FR_ACT_GOTO) */
Thomas Graf14c0b972006-08-04 03:38:38 -070050 FRA_UNUSED2,
51 FRA_PRIORITY, /* priority/preference */
52 FRA_UNUSED3,
53 FRA_UNUSED4,
54 FRA_UNUSED5,
Thomas Grafb8964ed2006-11-09 15:22:18 -080055 FRA_FWMARK, /* mark */
Thomas Graf14c0b972006-08-04 03:38:38 -070056 FRA_FLOW, /* flow/class id */
Thomas Grafe7030872015-07-21 10:44:01 +020057 FRA_TUN_ID,
Stefan Tomanek6ef94cf2013-08-02 17:19:56 +020058 FRA_SUPPRESS_IFGROUP,
Stefan Tomanek73f56982013-08-03 14:14:43 +020059 FRA_SUPPRESS_PREFIXLEN,
Patrick McHardy9e762a42006-08-10 23:09:48 -070060 FRA_TABLE, /* Extended table id */
Patrick McHardybbfb39c2006-08-25 16:10:14 -070061 FRA_FWMASK, /* mask for netfilter mark */
Patrick McHardy1b038a52009-12-03 01:25:56 +000062 FRA_OIFNAME,
Nicolas Dichtelb46f6de2016-04-22 17:31:18 +020063 FRA_PAD,
David Ahern96c63fa2016-06-08 10:55:39 -070064 FRA_L3MDEV, /* iif or oif is l3mdev goto its table */
Lorenzo Colitti622ec2c2016-11-04 02:23:42 +090065 FRA_UID_RANGE, /* UID range */
Donald Sharp1b71af62018-02-23 14:01:52 -050066 FRA_PROTOCOL, /* Originator of the rule */
Roopa Prabhubfff4862018-02-28 22:40:16 -050067 FRA_IP_PROTO, /* ip proto */
68 FRA_SPORT_RANGE, /* sport */
69 FRA_DPORT_RANGE, /* dport */
Thomas Graf14c0b972006-08-04 03:38:38 -070070 __FRA_MAX
71};
72
73#define FRA_MAX (__FRA_MAX - 1)
74
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080075enum {
Thomas Graf14c0b972006-08-04 03:38:38 -070076 FR_ACT_UNSPEC,
77 FR_ACT_TO_TBL, /* Pass to fixed table */
Thomas Graf0947c9fe2007-03-26 17:14:15 -070078 FR_ACT_GOTO, /* Jump to another rule */
Thomas Graffa0b2d12007-03-26 17:38:53 -070079 FR_ACT_NOP, /* No operation */
Thomas Graf14c0b972006-08-04 03:38:38 -070080 FR_ACT_RES3,
81 FR_ACT_RES4,
82 FR_ACT_BLACKHOLE, /* Drop without notification */
83 FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */
84 FR_ACT_PROHIBIT, /* Drop with EACCES */
85 __FR_ACT_MAX,
86};
87
88#define FR_ACT_MAX (__FR_ACT_MAX - 1)
89
90#endif