summaryrefslogtreecommitdiff
path: root/pbrd/pbr_vrf.h
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-09-27 16:38:31 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2019-11-21 16:59:42 -0500
commitbe3b67b5ef82d2f1f9f0f63190dd65c2bc47ebbf (patch)
tree47fdc3253148c9b0e9f31ebf8e71afcc7993e99f /pbrd/pbr_vrf.h
parent2d7ef3bba7eeb00adf2aceeca4747b59f4ac5fc7 (diff)
pbrd: Add `set vrf NAME` and `set vrf unchanged`
`set vrf NAME` allows the pbr map to point to an arbitrary vrf table. `set vrf unchanged` will use the interface's vrf for table lookup. Further, add functionality for pbr to respond to interface events such as interface vrf changes & interface creation/deletion. Ex) ubuntu_nh# show pbr map pbr-map TEST valid: 1 Seq: 1 rule: 300 Installed: 3(1) Reason: Valid SRC Match: 3.3.3.3/32 VRF Unchanged (use interface vrf) pbr-map TEST2 valid: 1 Seq: 2 rule: 301 Installed: 3(2) Reason: Valid SRC Match: 4.4.4.4/32 VRF Lookup: vrf-red root@ubuntu_nh:/home# ip rule show 0: from all lookup local 300: from 3.3.3.3 iif dummy2 lookup main 300: from 3.3.3.3 iif dummyVRF lookup 1111 301: from 4.4.4.4 iif dummy1 lookup 1111 301: from 4.4.4.4 iif dummy3 lookup 1111 Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com-
Diffstat (limited to 'pbrd/pbr_vrf.h')
-rw-r--r--pbrd/pbr_vrf.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/pbrd/pbr_vrf.h b/pbrd/pbr_vrf.h
new file mode 100644
index 0000000000..c9448762eb
--- /dev/null
+++ b/pbrd/pbr_vrf.h
@@ -0,0 +1,43 @@
+/*
+ * VRF library for PBR
+ * Copyright (C) 2019 Cumulus Networks, Inc.
+ * Stephen Worley
+ *
+ * FRR is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __PBR_VRF_H__
+#define __PBR_VRF_H__
+
+struct pbr_vrf {
+ struct vrf *vrf;
+};
+
+static inline const char *pbr_vrf_name(const struct pbr_vrf *pbr_vrf)
+{
+ return pbr_vrf->vrf->name;
+}
+
+static inline vrf_id_t pbr_vrf_id(const struct pbr_vrf *pbr_vrf)
+{
+ return pbr_vrf->vrf->vrf_id;
+}
+
+extern struct pbr_vrf *pbr_vrf_lookup_by_id(vrf_id_t vrf_id);
+extern struct pbr_vrf *pbr_vrf_lookup_by_name(const char *name);
+extern bool pbr_vrf_is_valid(const struct pbr_vrf *pbr_vrf);
+extern bool pbr_vrf_is_enabled(const struct pbr_vrf *pbr_vrf);
+
+extern void pbr_vrf_init(void);
+#endif