]>
git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_pbr.h
2 * Zebra Policy Based Routing (PBR) Data structures and definitions
3 * These are public definitions referenced by multiple files.
4 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * This file is part of FRR.
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FRR; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
37 * The filter or match criteria in a PBR rule.
38 * For simplicity, all supported filters are grouped into a structure rather
39 * than delineating further. A bitmask denotes which filters are actually
42 struct zebra_pbr_filter
{
44 #define PBR_FILTER_SRC_IP (1 << 0)
45 #define PBR_FILTER_DST_IP (1 << 1)
46 #define PBR_FILTER_SRC_PORT (1 << 2)
47 #define PBR_FILTER_DST_PORT (1 << 3)
49 /* Source and Destination IP address with masks. */
53 /* Source and Destination higher-layer (TCP/UDP) port numbers. */
58 #define IS_RULE_FILTERING_ON_SRC_IP(r) \
59 (r->filter.filter_bm & PBR_FILTER_SRC_IP)
60 #define IS_RULE_FILTERING_ON_DST_IP(r) \
61 (r->filter.filter_bm & PBR_FILTER_DST_IP)
62 #define IS_RULE_FILTERING_ON_SRC_PORT(r) \
63 (r->filter.filter_bm & PBR_FILTER_SRC_PORT)
64 #define IS_RULE_FILTERING_ON_DST_PORT(r) \
65 (r->filter.filter_bm & PBR_FILTER_DST_PORT)
70 * The action corresponding to a PBR rule.
71 * While the user specifies the action in a particular way, the forwarding
72 * plane implementation (Linux only) requires that to be encoded into a
73 * route table and the rule then point to that route table; in some cases,
74 * the user criteria may directly point to a table too.
76 struct zebra_pbr_action
{
83 * This is a combination of the filter criteria and corresponding action.
84 * Rules also have a user-defined sequence number which defines the relative
85 * order amongst rules.
87 struct zebra_pbr_rule
{
89 * Originating zclient sock fd, so we can know who to send
96 struct interface
*ifp
;
98 struct zebra_pbr_filter filter
;
99 struct zebra_pbr_action action
;
102 void zebra_pbr_add_rule(struct zebra_ns
*zns
, struct zebra_pbr_rule
*rule
);
103 void zebra_pbr_del_rule(struct zebra_ns
*zns
, struct zebra_pbr_rule
*rule
);
106 * Install specified rule for a specific interface.
107 * It is possible that the user-defined sequence number and the one in the
108 * forwarding plane may not coincide, hence the API requires a separate
109 * rule priority - maps to preference/FRA_PRIORITY on Linux.
111 extern void kernel_add_pbr_rule(struct zebra_pbr_rule
*rule
);
114 * Uninstall specified rule for a specific interface.
116 extern void kernel_del_pbr_rule(struct zebra_pbr_rule
*rule
);
119 * Get to know existing PBR rules in the kernel - typically called at startup.
121 extern void kernel_read_pbr_rules(struct zebra_ns
*zns
);
123 enum southbound_results
;
125 * Handle success or failure of rule (un)install in the kernel.
127 extern void kernel_pbr_rule_add_del_status(struct zebra_pbr_rule
*rule
,
128 enum southbound_results res
);
131 * Handle rule delete notification from kernel.
133 extern int kernel_pbr_rule_del(struct zebra_pbr_rule
*rule
);
135 extern void zebra_pbr_rules_free(void *arg
);
136 extern uint32_t zebra_pbr_rules_hash_key(void *arg
);
137 extern int zebra_pbr_rules_hash_equal(const void *arg1
, const void *arg2
);
138 #endif /* _ZEBRA_PBR_H */