Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: add PBR script wrapper framework to interact with script #2025

Closed
wants to merge 12 commits into from

Conversation

pguibert6WIND
Copy link
Member

@pguibert6WIND pguibert6WIND commented Apr 4, 2018

This framework has 2 kinds of APIs:

  • configuration APIs : configuring ipset, or iptable, or ip rule context.
  • monitoring APIs: dump statistics from running a wrap script.

This framework permits gaining time, since it allows frr to call some
external programs and rely on externals like the output.

Signed-off-by: Philippe Guibert [email protected]

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 4, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 0ecf1bb
Date 04/04/2018
Start 08:00:19
Finish 08:23:13
Run-Time 22:54
Total 1813
Pass 1813
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-04-08:00:19.txt
Log autoscript-2018-04-04-08:01:07.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3209/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_wrap_script.c
===============================================
WARNING: line over 80 characters
#64: FILE: /tmp/f1-14614/zebra_wrap_script.c:64:
+ *     0     0     DROP      all --  any   any anywhere  anywhere      match-set match0x55f44

WARNING: line over 80 characters
#66: FILE: /tmp/f1-14614/zebra_wrap_script.c:66:
+ * json_obj_list : the json structure mapped to the output, ranked with linu number

WARNING: line over 80 characters
#68: FILE: /tmp/f1-14614/zebra_wrap_script.c:68:
+ * { "2":{"pkts":"0","bytes":"0","target":"MARK","prot":"all","opt":"--","in":"any",..}}

ERROR: need consistent spacing around '*' (ctx:WxV)
#77: FILE: /tmp/f1-14614/zebra_wrap_script.c:77:
+	FILE *fp;
 	     ^
--
WARNING: line over 80 characters
#96: FILE: /tmp/f1-14614/zebra_wrap_script.c:96:
+			zlog_err("NETLINK: error closing stream with %s", script);

WARNING: line over 80 characters
#113: FILE: /tmp/f1-14614/zebra_wrap_script.c:113:
+					   (int)strlen(current_str), current_str);

WARNING: line over 80 characters
#131: FILE: /tmp/f1-14614/zebra_wrap_script.c:131:
+					/* a word is made up of a char or a digit

WARNING: line over 80 characters
#135: FILE: /tmp/f1-14614/zebra_wrap_script.c:135:
+					    (isalpha(current_str[k]) || isdigit(current_str[k])

WARNING: line over 80 characters
#136: FILE: /tmp/f1-14614/zebra_wrap_script.c:136:
+					     || (current_str[k] > 0x21 && current_str[k] < 0x2f))) {

WARNING: line over 80 characters
#150: FILE: /tmp/f1-14614/zebra_wrap_script.c:150:
+						if (zebra_wrap_debug & SCRIPT_ITEM_LIST)

WARNING: Too many leading tabs - consider code refactoring
#150: FILE: /tmp/f1-14614/zebra_wrap_script.c:150:
+						if (zebra_wrap_debug & SCRIPT_ITEM_LIST)

WARNING: line over 80 characters
#151: FILE: /tmp/f1-14614/zebra_wrap_script.c:151:
+							zlog_err("SCRIPT: (%d)ITEM %s ", nb_items, current_word);

WARNING: line over 80 characters
#152: FILE: /tmp/f1-14614/zebra_wrap_script.c:152:
+						item[nb_items].name = XSTRDUP(MTYPE_TMP, current_word);

WARNING: Too many leading tabs - consider code refactoring
#154: FILE: /tmp/f1-14614/zebra_wrap_script.c:154:
+						if (!item[nb_items].name) {

WARNING: line over 80 characters
#155: FILE: /tmp/f1-14614/zebra_wrap_script.c:155:
+							item[nb_items].name = XSTRDUP(MTYPE_TMP, "misc");

WARNING: line over 80 characters
#157: FILE: /tmp/f1-14614/zebra_wrap_script.c:157:
+							item[nb_items].attribute = XSTRDUP(MTYPE_TMP, current_word);

WARNING: line over 80 characters
#158: FILE: /tmp/f1-14614/zebra_wrap_script.c:158:
+						} else if (item[nb_items].attribute) {

WARNING: Too many leading tabs - consider code refactoring
#158: FILE: /tmp/f1-14614/zebra_wrap_script.c:158:
+						} else if (item[nb_items].attribute) {

WARNING: line over 80 characters
#159: FILE: /tmp/f1-14614/zebra_wrap_script.c:159:
+							/* store last elements in attribute

WARNING: line over 80 characters
#161: FILE: /tmp/f1-14614/zebra_wrap_script.c:161:
+							char temp_word[DATA_LINE_MAX];

WARNING: line over 80 characters
#166: FILE: /tmp/f1-14614/zebra_wrap_script.c:166:
+								 item[nb_items].attribute,

WARNING: line over 80 characters
#168: FILE: /tmp/f1-14614/zebra_wrap_script.c:168:
+							XFREE(MTYPE_TMP, item[nb_items].attribute);

WARNING: line over 80 characters
#169: FILE: /tmp/f1-14614/zebra_wrap_script.c:169:
+							item[nb_items].attribute =

WARNING: line over 80 characters
#170: FILE: /tmp/f1-14614/zebra_wrap_script.c:170:
+								XSTRDUP(MTYPE_TMP, temp_word);

WARNING: Too many leading tabs - consider code refactoring
#172: FILE: /tmp/f1-14614/zebra_wrap_script.c:172:
+						if (!keep_item) {

WARNING: line over 80 characters
#173: FILE: /tmp/f1-14614/zebra_wrap_script.c:173:
+							json_object_string_add(json_obj,

WARNING: line over 80 characters
#174: FILE: /tmp/f1-14614/zebra_wrap_script.c:174:
+								       item[nb_items].name,

WARNING: line over 80 characters
#175: FILE: /tmp/f1-14614/zebra_wrap_script.c:175:
+								       current_word);

WARNING: line over 80 characters
#176: FILE: /tmp/f1-14614/zebra_wrap_script.c:176:
+							if (zebra_wrap_debug & SCRIPT_ELEMENT_LIST)

WARNING: Too many leading tabs - consider code refactoring
#176: FILE: /tmp/f1-14614/zebra_wrap_script.c:176:
+							if (zebra_wrap_debug & SCRIPT_ELEMENT_LIST)

WARNING: line over 80 characters
#178: FILE: /tmp/f1-14614/zebra_wrap_script.c:178:
+									 nb_items,item[nb_items].name,

ERROR: space required after that ',' (ctx:VxV)
#178: FILE: /tmp/f1-14614/zebra_wrap_script.c:178:
+									 nb_items,item[nb_items].name,
 									         ^
--
WARNING: line over 80 characters
#179: FILE: /tmp/f1-14614/zebra_wrap_script.c:179:
+									 current_word);

WARNING: line over 80 characters
#187: FILE: /tmp/f1-14614/zebra_wrap_script.c:187:
+						for (m = 0; m < ITEM_MAXIMUM; m++)

WARNING: Too many leading tabs - consider code refactoring
#187: FILE: /tmp/f1-14614/zebra_wrap_script.c:187:
+						for (m = 0; m < ITEM_MAXIMUM; m++)

WARNING: line over 80 characters
#188: FILE: /tmp/f1-14614/zebra_wrap_script.c:188:
+							XFREE(MTYPE_TMP, item[m].name);

WARNING: line over 80 characters
#198: FILE: /tmp/f1-14614/zebra_wrap_script.c:198:
+							       item[nb_items].name,

WARNING: line over 80 characters
#199: FILE: /tmp/f1-14614/zebra_wrap_script.c:199:
+							       item[nb_items].attribute);

WARNING: line over 80 characters
#202: FILE: /tmp/f1-14614/zebra_wrap_script.c:202:
+							 nb_items,item[nb_items].name,

ERROR: space required after that ',' (ctx:VxV)
#202: FILE: /tmp/f1-14614/zebra_wrap_script.c:202:
+							 nb_items,item[nb_items].name,
 							         ^
--
WARNING: line over 80 characters
#203: FILE: /tmp/f1-14614/zebra_wrap_script.c:203:
+							 item[nb_items].attribute);

WARNING: line over 80 characters
#204: FILE: /tmp/f1-14614/zebra_wrap_script.c:204:
+					XFREE(MTYPE_TMP, item[nb_items].attribute);

WARNING: line over 80 characters
#212: FILE: /tmp/f1-14614/zebra_wrap_script.c:212:
+					snprintf(line, sizeof(line), "%d", line_nb);

WARNING: line over 80 characters
#213: FILE: /tmp/f1-14614/zebra_wrap_script.c:213:
+					json_object_object_add(json_obj_list, line, json_obj);

CLANG Static Analyzer Summary

  • Github Pull Request 2025, comparing to Git base SHA 78f0e7d

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3209/artifact/shared/static_analysis/index.html

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 4, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 9411fdd
Date 04/04/2018
Start 12:40:14
Finish 13:03:13
Run-Time 22:59
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-04-12:40:14.txt
Log autoscript-2018-04-04-12:41:01.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3211/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_wrap_script.c
===============================================
WARNING: Too many leading tabs - consider code refactoring
#160: FILE: /tmp/f1-29293/zebra_wrap_script.c:160:
+						if (zebra_wrap_debug

WARNING: line over 80 characters
#163: FILE: /tmp/f1-29293/zebra_wrap_script.c:163:
+								 nb_items, current_word);

WARNING: line over 80 characters
#165: FILE: /tmp/f1-29293/zebra_wrap_script.c:165:
+							XSTRDUP(MTYPE_TMP, current_word);

WARNING: Too many leading tabs - consider code refactoring
#167: FILE: /tmp/f1-29293/zebra_wrap_script.c:167:
+						if (!item[nb_items].name) {

WARNING: line over 80 characters
#169: FILE: /tmp/f1-29293/zebra_wrap_script.c:169:
+								XSTRDUP(MTYPE_TMP, "misc");

WARNING: line over 80 characters
#171: FILE: /tmp/f1-29293/zebra_wrap_script.c:171:
+							item[nb_items].attribute =

WARNING: line over 80 characters
#172: FILE: /tmp/f1-29293/zebra_wrap_script.c:172:
+								XSTRDUP(MTYPE_TMP,

WARNING: line over 80 characters
#173: FILE: /tmp/f1-29293/zebra_wrap_script.c:173:
+									current_word);

WARNING: line over 80 characters
#174: FILE: /tmp/f1-29293/zebra_wrap_script.c:174:
+						} else if (item[nb_items].attribute) {

WARNING: Too many leading tabs - consider code refactoring
#174: FILE: /tmp/f1-29293/zebra_wrap_script.c:174:
+						} else if (item[nb_items].attribute) {

WARNING: line over 80 characters
#175: FILE: /tmp/f1-29293/zebra_wrap_script.c:175:
+							/* store last elements in attribute

WARNING: line over 80 characters
#177: FILE: /tmp/f1-29293/zebra_wrap_script.c:177:
+							char temp_word[DATA_LINE_MAX];

WARNING: line over 80 characters
#182: FILE: /tmp/f1-29293/zebra_wrap_script.c:182:
+								 item[nb_items].attribute,

WARNING: line over 80 characters
#185: FILE: /tmp/f1-29293/zebra_wrap_script.c:185:
+							      item[nb_items].attribute);

WARNING: line over 80 characters
#186: FILE: /tmp/f1-29293/zebra_wrap_script.c:186:
+							item[nb_items].attribute =

WARNING: line over 80 characters
#187: FILE: /tmp/f1-29293/zebra_wrap_script.c:187:
+								XSTRDUP(MTYPE_TMP,

WARNING: line over 80 characters
#188: FILE: /tmp/f1-29293/zebra_wrap_script.c:188:
+									temp_word);

WARNING: Too many leading tabs - consider code refactoring
#190: FILE: /tmp/f1-29293/zebra_wrap_script.c:190:
+						if (!keep_item) {

WARNING: line over 80 characters
#191: FILE: /tmp/f1-29293/zebra_wrap_script.c:191:
+							json_object_string_add(json_obj,

WARNING: line over 80 characters
#192: FILE: /tmp/f1-29293/zebra_wrap_script.c:192:
+								       item[nb_items].name,

WARNING: line over 80 characters
#193: FILE: /tmp/f1-29293/zebra_wrap_script.c:193:
+								       current_word);

WARNING: Too many leading tabs - consider code refactoring
#194: FILE: /tmp/f1-29293/zebra_wrap_script.c:194:
+							if (zebra_wrap_debug

WARNING: line over 80 characters
#195: FILE: /tmp/f1-29293/zebra_wrap_script.c:195:
+							    & SCRIPT_ELEMENT_LIST)

WARNING: quoted string split across lines
#197: FILE: /tmp/f1-29293/zebra_wrap_script.c:197:
+								zlog_err("(%d)ITEM Obtained "
+									 "for %s is %s",
--
WARNING: line over 80 characters
#198: FILE: /tmp/f1-29293/zebra_wrap_script.c:198:
+									 nb_items,

WARNING: line over 80 characters
#199: FILE: /tmp/f1-29293/zebra_wrap_script.c:199:
+									 item[nb_items].name,

WARNING: line over 80 characters
#200: FILE: /tmp/f1-29293/zebra_wrap_script.c:200:
+									 current_word);

WARNING: line over 80 characters
#208: FILE: /tmp/f1-29293/zebra_wrap_script.c:208:
+						for (m = 0; m < ITEM_MAXIMUM; m++)

WARNING: Too many leading tabs - consider code refactoring
#208: FILE: /tmp/f1-29293/zebra_wrap_script.c:208:
+						for (m = 0; m < ITEM_MAXIMUM; m++)

WARNING: line over 80 characters
#209: FILE: /tmp/f1-29293/zebra_wrap_script.c:209:
+							XFREE(MTYPE_TMP, item[m].name);

WARNING: line over 80 characters
#219: FILE: /tmp/f1-29293/zebra_wrap_script.c:219:
+							       item[nb_items].name,

WARNING: line over 80 characters
#220: FILE: /tmp/f1-29293/zebra_wrap_script.c:220:
+							       item[nb_items].attribute);

WARNING: line over 80 characters
#223: FILE: /tmp/f1-29293/zebra_wrap_script.c:223:
+							 nb_items,item[nb_items].name,

ERROR: space required after that ',' (ctx:VxV)
#223: FILE: /tmp/f1-29293/zebra_wrap_script.c:223:
+							 nb_items,item[nb_items].name,
 							         ^
--
WARNING: line over 80 characters
#224: FILE: /tmp/f1-29293/zebra_wrap_script.c:224:
+							 item[nb_items].attribute);

WARNING: line over 80 characters
#225: FILE: /tmp/f1-29293/zebra_wrap_script.c:225:
+					XFREE(MTYPE_TMP, item[nb_items].attribute);

WARNING: line over 80 characters
#233: FILE: /tmp/f1-29293/zebra_wrap_script.c:233:
+					snprintf(line, sizeof(line), "%d", line_nb);

WARNING: line over 80 characters
#234: FILE: /tmp/f1-29293/zebra_wrap_script.c:234:
+					json_object_object_add(json_obj_list, line, json_obj);

CLANG Static Analyzer Summary

  • Github Pull Request 2025, comparing to Git base SHA ce7b915

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3211/artifact/shared/static_analysis/index.html

@pguibert6WIND
Copy link
Member Author

example of json format returned

{
  "0":{
    "pkts":"0",
    "bytes":"0",
    "target":"MARK",
    "prot":"all",
    "opt":"--",
    "in":"any",
    "out":"any",
    "source":"anywhere",
    "destination":"anywhere",
    "misc":"match-set match0x52bb980 dst MARK set 0x100"
  },
  "1":{
    "pkts":"0",
    "bytes":"0",
    "target":"MARK",
    "prot":"all",
    "opt":"--",
    "in":"any",
    "out":"any",
    "source":"anywhere",
    "destination":"anywhere",
    "misc":"match-set match0x52bb770 src MARK set 0x100"
  },
  "2":{
    "pkts":"0",
    "bytes":"0",
    "target":"MARK",
    "prot":"all",
    "opt":"--",
    "in":"any",
    "out":"any",
    "source":"anywhere",
    "destination":"anywhere",
    "misc":"match-set match0x52bb2a0 src,dst,dst MARK set 0x100"
  },
  "3":{
    "pkts":"0",
    "bytes":"0",
    "target":"MARK",
    "prot":"all",
    "opt":"--",
    "in":"any",
    "out":"any",
    "source":"anywhere",
    "destination":"anywhere",
    "misc":"match-set match0x52bb080 dst,dst MARK set 0x100"
  }
}

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: FAILED

See below for issues.
CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Get source and apply patch from patchwork: Successful

Building Stage: Failed

Fedora24 amd64 build: Successful
Ubuntu1204 amd64 build: Successful
Ubuntu1404 amd64 build: Successful
FreeBSD11 amd64 build: Successful
NetBSD6 amd64 build: Successful
OmniOS amd64 build: Successful
CentOS7 amd64 build: Successful
CentOS6 amd64 build: Successful
OpenBSD60 amd64 build: Successful
FreeBSD10 amd64 build: Successful
NetBSD7 amd64 build: Successful
FreeBSD9 amd64 build: Successful

Ubuntu1604 amd64 build: Failed

Package building failed for Ubuntu1604 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI014BUILD/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Ubuntu1604 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI014BUILD/config.status/config.status

Ubuntu 16.04 i386: Failed

Ubuntu 16.04 i386: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/U1604I386/config.status/config.status
Package building failed for Ubuntu 16.04 i386:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/U1604I386/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Debian8 amd64 build: Failed

Package building failed for Debian8 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI008BLD/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Debian8 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI008BLD/config.status/config.status

Debian9 amd64 build: Failed

Debian9 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI021BUILD/config.status/config.status
Package building failed for Debian9 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI021BUILD/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Warnings Generated during build:

Checkout code: Successful with additional warnings:

Ubuntu1604 amd64 build: Failed

Package building failed for Ubuntu1604 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI014BUILD/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Ubuntu1604 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI014BUILD/config.status/config.status

Ubuntu 16.04 i386: Failed

Ubuntu 16.04 i386: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/U1604I386/config.status/config.status
Package building failed for Ubuntu 16.04 i386:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/U1604I386/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Debian8 amd64 build: Failed

Package building failed for Debian8 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI008BLD/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \

Debian8 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI008BLD/config.status/config.status

Debian9 amd64 build: Failed

Debian9 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI021BUILD/config.status/config.status
Package building failed for Debian9 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3221/artifact/CI021BUILD/ErrorLog/log_package_build.txt)

dh: Unknown sequence debian/backports/rules (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
if ! [ -e config.status ]; then \
dh_auto_configure -- \
	--enable-exampledir=/usr/share/doc/frr/examples/ \
	--localstatedir=/var/run/frr \
	--sbindir=/usr/lib/frr \


Report for zebra_wrap_script.c
===============================================
ERROR: space prohibited before that '++' (ctx:WxO)
#71: FILE: /tmp/f1-16599/zebra_wrap_script.c:71:
+		m ++;
 		  ^
--
WARNING: quoted string split across lines
#159: FILE: /tmp/f1-16599/zebra_wrap_script.c:159:
+					zlog_err("(%d)ITEM Obtained "
+						 "for %s is %s",
--
ERROR: space required after that ',' (ctx:VxV)
#185: FILE: /tmp/f1-16599/zebra_wrap_script.c:185:
+				 nb_items,item[nb_items].name,
 				         ^
--
WARNING: line over 80 characters
#267: FILE: /tmp/f1-16599/zebra_wrap_script.c:267:
+				json_object_object_add(json_obj_list, line, json_obj);

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 5, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 992eb7f
Date 04/05/2018
Start 04:45:13
Finish 05:08:13
Run-Time 23:00
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-05-04:45:13.txt
Log autoscript-2018-04-05-04:46:02.log.bz2

For details, please contact louberger

* "opt":"--","in":"any",..}}
*/

int zebra_wrap_script(char *script, bool return_data,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know "const" is under used in FRR, but whevenever possible, it should. For instance, here "char *script" is clearly a const.

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3225/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_wrap_script.c
===============================================
ERROR: space prohibited before that '++' (ctx:WxO)
#70: FILE: /tmp/f1-27328/zebra_wrap_script.c:70:
+		m ++;
 		  ^
--
WARNING: quoted string split across lines
#158: FILE: /tmp/f1-27328/zebra_wrap_script.c:158:
+					zlog_err("(%d)ITEM Obtained "
+						 "for %s is %s",
--
ERROR: space required after that ',' (ctx:VxV)
#184: FILE: /tmp/f1-27328/zebra_wrap_script.c:184:
+				 nb_items,item[nb_items].name,
 				         ^
--
WARNING: line over 80 characters
#266: FILE: /tmp/f1-27328/zebra_wrap_script.c:266:
+				json_object_object_add(json_obj_list, line, json_obj);

CLANG Static Analyzer Summary

  • Github Pull Request 2025, comparing to Git base SHA 0c842c4

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3225/artifact/shared/static_analysis/index.html

@donaldsharp
Copy link
Member

What's the end goal of this patchset? I see comments in the code to get access to iptables output. Why are we exposing ourselves to allowing the execution of arbitrary scripts? It sure seems if we need access to iptables information from the kernel we should use the kernels abi for it.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 5, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 372764e
Date 04/05/2018
Start 14:33:11
Finish 14:56:18
Run-Time 23:07
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-05-14:33:11.txt
Log autoscript-2018-04-05-14:33:59.log.bz2

For details, please contact louberger

Copy link
Member

@qlyoung qlyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have various problems with this code.

  1. Code usage is unclear and functions are named poorly.
  2. This is clearly intended to be used for parsing the output of iptables. iptables requires root and therefore you either plan to run zebra as root without privilege dropping, or with iptables as setuid root. Both of these seem like bad ideas. I also do not understand why we would want to read iptables rules in Zebra.
  3. The ability to invoke the shell from Zebra makes me uncomfortable and I don't see a strong enough justification for the very likely security holes this will open in the future.
  4. Any script output not containing a whitespace will segfault the program.
  5. This code as written contains an exploitable buffer overflow due to an unchecked memcpy. Output exceeding 200 characters followed by a space will overwrite the stack frame of handle_field_line with the data between the 201st character and the space.

}
}
if (pclose(fp))
zlog_err("NETLINK: error closing stream with %s", script);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does netlink have to do with this code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you re right.

static int zebra_wrap_debug;


void zebra_wrap_init(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary, statics with automatic storage duration are initialized to zero automatically

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

zebra_wrap_debug = 0;
}

static int search_current_word(char *current_str, int init,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clearly built to process iptables output, it should be named as such.
However, this also does essentially the exact same thing as strsep, doesn't it? Have you considered using strsep?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet. I think strsep or strchr could be helpful.

for iptable output process, I think of keeping the name very generic, so that this kind of function can be applied to not only iptables but also other functions ( ipset ?)

return -1;
}

static int handle_field_line(struct json_object *json_obj,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as search_current_word.

* # iptables -t mangle -L PREROUTING -v
* Chain PREROUTING (policy ACCEPT 150k packets, 7426 bytes) (## line 0)
* pkts bytes target prot opt in out source destination (## line 1)
* 0 0 DROP all -- any any anywhere anywhere
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example, and the code above to parse this output, makes me uncomfortable. It implies you are running Zebra as root, or expect users of this to be running Zebra as root, or perhaps that you have setuid root on iptables, all three of which are bad ideas...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. there are assumptions done.

if (line_nb > begin_at_line)
json_obj = json_object_new_object();
else
json_obj = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only time this executes is when line_nb == begin_at_line, is that the intent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idealle, you can split function in two:

  • one that looks for headers
  • the other one that looks for entries

@pguibert6WIND
Copy link
Member Author

pguibert6WIND commented Apr 6, 2018

some responses that may help to understand the feature:

  • I agree code function name is poor.
    I don't expect immediate acceptance. this is more like a Proof of Concept for now.
    keep in mind that this tool may be used to dump some information from various underlying services.
    and not only iptables
  • that patch set also does not respond to privileges rights to access to such output.
    Actually, I plan to move that library to lib/ folder, so that privileges will have to be done on the caller location.

I think this pull request ( and the ticket attached) is the good location to discuss on the ability to invoke the shell from Zebra.
Q1 : why invoking shell ?
as I mentioned in ticket, this increases the speed to get some additional information.
Before digging in netlink API, I find that very simple to use. It brings me benefits in time and feature, faster than if I had to encode the whole netlink layer to configure or monitor iptables.

Also, an other advantage of relying on scripts is in the multiple OS part. Because ABI is clearly identified on Linux, this may not be the case for other Oses. For instance, in order to benefit from iptables on non Linux system, one would have to implement a new backend that would be different from the netlink. Here, if iptables is available on a non linux system, I offer the possibility to have one script backend that is available everywhere.

Q2 : why calling from Zebra ? This is contextual. In my case, I make policy-routing from BGP Flowspec.
Flowspec uses iptables ( and ipset, and ip rule) to redirect IPv4 unicast traffic embraced by FS.
Those iptables need to be configured and monitored ( statistics)
Originally, zebra does the netlink job. So, it sounds natural that zebra continues to do that job.
This being said, the need may be enlarged to other daemons. to collect statistics, do we need to rely on zebra ? Could not we use directly BGP daemon ?

It sure seems if we need access to iptables information from the kernel
we should use the kernels abi for it

from the POC perspective, could not we allow ( I don't know, temporarily or on a compilation define basis) the opening to rely on a script extension ?
BGP FS has a lot of combinations possible. Providing scripts may be easier for access than using netlink internals not known by everyone. I mean, proposing script is a way to try to make gain acceptance to more people.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 6, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 d95940a
Date 04/06/2018
Start 05:20:13
Finish 05:43:09
Run-Time 22:56
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-06-05:20:13.txt
Log autoscript-2018-04-06-05:21:01.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3230/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_wrap_script.c
===============================================
ERROR: space prohibited before that '++' (ctx:WxO)
#65: FILE: /tmp/f1-31011/zebra_wrap_script.c:65:
+		m ++;
 		  ^
--
WARNING: quoted string split across lines
#161: FILE: /tmp/f1-31011/zebra_wrap_script.c:161:
+					zlog_err("(%d)ITEM Obtained "
+						 "for %s is %s",
--
ERROR: space required after that ',' (ctx:VxV)
#187: FILE: /tmp/f1-31011/zebra_wrap_script.c:187:
+				 nb_items,item[nb_items].name,
 				         ^
--
WARNING: line over 80 characters
#269: FILE: /tmp/f1-31011/zebra_wrap_script.c:269:
+				json_object_object_add(json_obj_list, line, json_obj);

CLANG Static Analyzer Summary

  • Github Pull Request 2025, comparing to Git base SHA 0c842c4

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3230/artifact/shared/static_analysis/index.html

@pguibert6WIND
Copy link
Member Author

The script will evolve, and I will inform you about an update of that script.

For the reason why using scripts, I would like some feedback : having a way to rely on scripts instead of netlink could extend the usage of FRR on not only linux platforms.
waiting for comments.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 9, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 457f1bd
Date 04/09/2018
Start 09:10:14
Finish 09:33:14
Run-Time 23:00
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-09-09:10:14.txt
Log autoscript-2018-04-09-09:11:01.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3260/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_wrap_script.c
===============================================
WARNING: quoted string split across lines
#161: FILE: /tmp/f1-8369/zebra_wrap_script.c:161:
+					zlog_err("(%d)ITEM Obtained "
+						 "for %s is %s",

CLANG Static Analyzer Summary

  • Github Pull Request 2025, comparing to Git base SHA 8227cf9

No Changes in Static Analysis warnings compared to base

20 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3260/artifact/shared/static_analysis/index.html

@rwestphal
Copy link
Member

from the POC perspective, could not we allow ( I don't know, temporarily or on a compilation define basis) the opening to rely on a script extension ?

I wonder why you want to upstream this functionality. I understand these wrappers can be useful during the early development phases of a new feature, but at some point you'll need to convert your code to use the right APIs. You can't escape from that, I'm pretty sure no one will merge code that depends on the text output of any script or tool.

You might argue these wrappers could benefit other developers, but I'm skeptical about that. Wouldn't it be possible for you to use these wrappers internally only?

Also, an other advantage of relying on scripts is in the multiple OS part. Because ABI is clearly identified on Linux, this may not be the case for other Oses. For instance, in order to benefit from iptables on non Linux system, one would have to implement a new backend that would be different from the netlink. Here, if iptables is available on a non linux system, I offer the possibility to have one script backend that is available everywhere.

The text output of several tools varies a lot among different platforms, relying on any specific format is just a bad thing to do.

@donaldsharp
Copy link
Member

In general I agree with @rwestphal that this is of dubious value for anyone. Especially since you'll be doing work twice( once in a script and once implementing the proper api ). Having said that, I do believe if the cli and the functionality here are wrappered inside of a module and a configure compile option the chance for damage is low and the code would either be maintained by @pguibert6WIND or not. If not maintained it would stop working and that is no skin off of my back.

@pguibert6WIND pguibert6WIND changed the title zebra: add script wrapper framework to interact with script zebra: add PBR script wrapper framework to interact with script Apr 23, 2018
@pguibert6WIND
Copy link
Member Author

@qlyoung , I will look into your comments, since I refactored the whole code.
afair , the strchr could not be called very easily.

because the parsed string may not have only one space, strchr would stop at the first occurency of space, while there are other occurences of spaces.

[SPACE][SPACE]..[SPACE]<WORD>[SPACE][SPACE][SPACE]

For your remarks, I think I will still need to review with your help.

  • code unclear and poorly function naming
  • some possible buffer overflow ( to be reviewed)

About the wrap script I done, let things be clear:

  • this is an API for configuring iptables / ipset / ip rule by using an other way than netlink.
  • those APIs returns a positive value if call succeded, -1, or 0 if it failed . this permits fallbacking to netlink ( if available).
  • for privileges, I still encountered an issue in those conditions. I think this is because I call popen, and popen is not authorized ( I need to get the correct PRIVS). However, if I compile with ./configure --disable-capabilities

for comments from @rwestphal and @donaldsharp , I think there has been acceptance of a using a module to host those wrap script apis. does not that mean that it is more than half-accepted ?

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 23, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 ab13bd1
Date 04/23/2018
Start 09:10:35
Finish 09:33:32
Run-Time 22:57
Total 1813
Pass 1813
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-23-09:10:35.txt
Log autoscript-2018-04-23-09:11:22.log.bz2

For details, please contact louberger

@rzalamena
Copy link
Member

@pguibert6WIND ,

Answering myself:


  1. What is the purpose of this PR implementation: Do you want to be able to execute remote scripts to configure iptables/ipset/ip rule that implements your business logic, or just feed FRR firewall information?

Watch flows, call scripts based on policy and keep statistics. Is this correct?


  1. How is the current code benefiting other systems than Linux?

I see this quote:

Also, this benefits also for systems not using Netlink. At the time of the writing, the
interface is used for configuring iptables, ipset, and iprule tools.

But the code seems to be only geared towards Linux with no *BSDs callbacks nor information - which is fine btw. Wouldn't it be expected to have a different format than the Linux tools output?

This is still unanswered. I'd expect at least a new output format from your scripts (or input) so we don't break on external tools change (iptables/ipset/ip rule etc...). This will also probably easen the development of your parsers in the future.


  1. zebra is supposed to handle a very select set of actions and it should be free to run more important things (like netlink communication) and not be blocked spawning and communication with processes (JSON strings handling might also be harmful). Why are all of these things being implemented in zebra?

This is also unanswered and it has been questioned by others. It is clear that implementing this feature here will severely degrade security and our capacity to lock down (at least zebra).

a. you are proposing to add more privileges to zebra, when it only need a few to open some system sockets;
b. you want to be able to execute scripts: this means that you want the exec (see how popen is implemented) capability which is wildly used by exploits to run evil stuff;
c. since you want to provide your scripts this will also mean we won't be able to chroot, so you can find all programs you need in PATH, like iptables/ipset/ip rule.
d. running scripts also means we have to bump limits to support bigger rate of executions of your scripts (statements inside shell scripts are usually other programs)
e. since you may want to log you'll have to expose syslog sockets or the /var/log folder, it may also open doors to malware wanting to flood your logs

Most of the points above can be avoided by using the kernel APIs directly. If you still want to go this way, why is this being implemented in zebra?

@daveolson53
Copy link
Contributor

This paragraph displays a major misunderstanding of security design and impact:

For security reasons, I agree we open the door.
But that may be a deliberate choice from the administrator to keep that open. To facilitate it, quagga user could be a sudoerr, and a script would be called instead of directly calling the function name ( eg: call bash /tmp/iptables instead of call iptables). Inside that script one would do sudo ...

An administrator has a reasonable belief that if a major software application provides a feature, that it is reasonably secure, and will remain that way.

That's not the case here.

The slide deck gives no indication that other designs or methods of implementation were considered, and why they weren't adopted.

Have you involved other folks at your company, particularly those concerned with software security? If not, I think that would be a really good idea.

I'm still seeing no reason from the slide deck that this would be best implemented directly inside zebra or other frr components via running programs and reading their output.

@pguibert6WIND
Copy link
Member Author

about the script configuration, the plugin module provides some script:
here is an example, on how I configure it when I link it with netfilters.

wrap script iptable iptables
wrap script ipset ipset

also, I plan to update the documentation. here is the first extract

If Wrap Script is enabled during compile-time and installed as part of the
package, the ``wrap_script`` module can be loaded for the *Zebra* daemon. This
provides the *Zebra* Script Wrapper interface to be available for handling
underlying firewall elements. Specifically, if the system where FRR is is Linux,
default firewall used is `Linux netfilters`. Note that the interface terminology
is tightly linked with `Linux netfilters` main objects, that is to say `iptables`
and `ipset`. But we will see that that module can configure or monitor other
similar objects.
Instead of using ioctl() operations, this wrap interface permits using either
underlying shell commands ( from where the FRR is based on) or custom scripts. This
can be done by using a vty command to configure which execution path to call for
`iptables` or `ipset` object. The vty commands can directly configure the native
Linux netfilter tools. Or the vty commands can reference external shell script that
will be called. This second case may be used for non Linux systems, or for users
that do not want to use netfilters, but want to use an other set of tools like `eBPF`
or `NFTables`.
The wrap script module proposes configuration APIs to create `ipset` and `iptables`
objects. Monitoring APIs will first return a json like format based on the output
of the 2 underlying objects. Here too, the format analysed is tightly linked with
the Linux format of `ipset` and `iptables`. However, even if the tools used are not
based on `Netfilter`, it will still be possible to use a strict to return json format
output similar to `ipset` and `iptables`.

I hope the above answers point 2 from Rafael.

For point 3, security, I say that zebra may be open a secuty hole, but I am sure the administrator has a full set of tools to manage not only FRR but the environment around. There are a lot of linux tools that permit customize security, by taking into account not only FRR but also some external scripting that may be called.

For point 3, netlink. iptables relies on ioctl, not netlink.

@pguibert6WIND
Copy link
Member Author

pguibert6WIND commented Apr 27, 2018

ok.
I will not have the time to push something today in relationship to what I mentioned earlier.

For security concerns, it seems everybody is against that ticket.
The security is someting to be taken care from the product perspective.
And from my perspective, FRR is a brick of the security, not the single brick to protect.
one can see multiple walls to protect the product, for instances...

However, the script answers my needs as I depicted it in the slide.
Doing policy-routing with flowspec and iptables is really nice.
And I also get the statistics of the incoming traffic. ( by the way, i think pbrd does not have it).
I have received no feedback from people that tried that script, but I can tell you that if I need to support ebpf to accelerate my traffic, it will be easier to do so.

@qlyoung
Copy link
Member

qlyoung commented Apr 27, 2018

And from my perspective, FRR is a brick of the security, not the single brick to protect.
one can see multiple walls to protect the product, for instances...

In your analogy, my opinion is that every brick ought to be as protected as it reasonably can be. Just because there are other methods of shielding FRR from attack does not mean we can ignore security from the FRR perspective. One might just as easily say "we have firewalls, so we can trust everything we receive on the network."

@pguibert6WIND
Copy link
Member Author

pguibert6WIND commented Apr 30, 2018

To @rzalamena ,

purpose of this PR implementatio

Watch flows, call scripts based on policy and keep statistics. Is this correct?

the purpose is both configuring Netfilter through scripting., and keep statistics.

How is the current code benefiting other systems than Linux?

I can configure the call in the script.
for instance nftables fits very well between netfilter config and the new firewall, by using scripting.
For keeping statistics, I think some more change in getting statistics may be necessary.
But I think this can be done later, on need.
The good point, I think is the usage of json to read statistics.
I let you look at following exameple:
Here is an extract on how I get an output from a shell command, and I grab it in json format.

shell# ipset --list match0x4e3cbc0
Name: match0x4e3cbc0
Type: hash:net,port,net
Revision: 2
Header: family inet hashsize 64 maxelem 65536 counters
Size in memory: 824
References: 1
Number of entries: 2
Members:
1.1.1.2,tcp:80,3.3.3.3 packets 7 bytes 420
1.1.1.2,udp:80,3.3.3.3 packets 606293 bytes 53353784

vtysh# show pbr ipset
IPset match0x4e3cbc0 type net,port,net
	from 1.1.1.2 to 3.3.3.3:udp/tcp:80 (10)
	 pkts 606300, bytes 53354204


extracted json output#
IPset match0x4e3cbc0 type net,port,net
{
  "0":{
    "Type":" hash:net,port,net\n"
  },
  "1":{
    "Revision":" 2\n"
  },
  "2":{
    "Header":" family inet hashsize 64 maxelem 65536 counters\n"
  },
  "3":{
    "Size":"in memory: 824\n"
  },
  "4":{
    "References":" 1\n"
  },
  "5":{
    "Number":"of entries: 2\n"
  },
  "6":{
    "data":"1.1.1.2,tcp:80,3.3.3.3",
    "pkts":"7",
    "bytes":"420"
  },
  "7":{
    "data":"1.1.1.2,udp:80,3.3.3.3",
    "pkts":"606293",
    "bytes":"53353784"
  }
}

It is clear that implementing this feature here will severely degrade security and our capacity to lock down

I admit those are unanswered issues.
As zebra will handle async queries, I think the way the script is launched may have to be rewritten ( but not impossible).
Security concerns is very sensitive subject also.
I think this is the reason why the pull request will not be accepted.

why is this being implemented in zebra?

maybe Rafael, you could help me on that point.
southbound calls are usually implemented in Zebra. right ?
Also the reason why I put it that in zebra is that I was seeing that pr as a new way to configure underlying system.
If you imagine you have a feature that is configurable with both netlink and ioctl, you may give the possiblity to the user to choose between both. no ?

Add ns_id into zebra_pbr ipset
This is important so that each ipset entry knows on which NETNS the
ipset entry must be inkected

Signed-off-by: Philippe Guibert <[email protected]>
This commit is a fix that removes the structure from the hash list,
instead of just removing that structure.

Signed-off-by: Philippe Guibert <[email protected]>
Upon the remote daemon leaving, some contexts may have to be flushed.
This commit does the change. IPset and IPSet Entries and iptables are
flushed.

Signed-off-by: Philippe Guibert <[email protected]>
In cast the removal of an iptable or an ipset pbr context is done,
then a notification is sent back to the relevant daemon that sent the
message.

Signed-off-by: Philippe Guibert <[email protected]>
When a mark is set, incoming traffic having that mark set can be
redirected to a specific table identifier. This work is done through
netlink.

Signed-off-by: Philippe Guibert <[email protected]>
This framework has 2 APIs,
- able to execute script show command, and return the output in
a json structure. Those script show command are tighted with iptables
and ipset output.
- able to analyse json tree, and extract pkts and bytes values.

This framework permits gaining time, since it allows frr to call some
external programs and rely on externals like the output.
This framework relies on plugin module. This module is called
zebra_wrap_script.

Signed-off-by: Philippe Guibert <[email protected]>
update documentation with zebra module script.

Signed-off-by: Philippe Guibert <[email protected]>
In order to configure iptables, ipset entries and ipset contexts, 2
script handlers apis are available to pass scripts commands.

Signed-off-by: Philippe Guibert <[email protected]>
This preparatory work introduces a new node that will be used to add vty
configuration commands, and the associated show running.

Signed-off-by: Philippe Guibert <[email protected]>
3 new vty commands permit to configure zebra wrap ip scripts:
- [no] wrap script ipset <>
- [no] wrap script iptable <>
- [no] wrap script iprule <>

Signed-off-by: Philippe Guibert <[email protected]>
The following PBR handlers: ip rule, ipset, and iptables will prioritary
call the wrap script handlers. If the script handler is not present ( or
returns 0 - that is why the script handlers may not return 0), then if
available an other configuration call may be called. This is the case
with ip rule PBR handler that also has a netlink API. This mechanism
guarantees that if wrap script can configure it, then no need to use
netlink.

Signed-off-by: Philippe Guibert <[email protected]>
Two new vty show functions available:
show pbr ipset <NAME>
show pbr iptables <NAME>

Those function dump the underlying "kernel" contexts. It relies on the
zebra pbr contexts first. This helps then to know which zebra pbr
context has been configured since those contexts are mainly configured
by BGP Flowspec.
Also, it relies on zebra wrap context API. From this wrap API, it gets
some statistics information to know which context has been matching how
many packets and bytes.

Signed-off-by: Philippe Guibert <[email protected]>
@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3486/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_pbr.c
===============================================
< WARNING: Missing a blank line after declarations
< #962: FILE: /tmp/f1-7663/zebra_pbr.c:962:
< +			struct zebra_pbr_rule *zpr = prfl.ptr;
< +			vty_out(vty, "\t table %u, fwmark %u\n",
Report for zebra_vty.c
===============================================
< WARNING: Missing a blank line after declarations
< #3376: FILE: /tmp/f1-7663/zebra_vty.c:3376:
---
> #3344: FILE: /tmp/f2-7663/zebra_vty.c:3344:
Report for zebra_wrap_script.c
===============================================
ERROR: space prohibited before that '++' (ctx:WxO)
#144: FILE: /tmp/f1-7663/zebra_wrap_script.c:144:
+		m ++;
 		  ^
--
WARNING: quoted string split across lines
#233: FILE: /tmp/f1-7663/zebra_wrap_script.c:233:
+			zlog_err("ITEM Obtained "
+				 "for %s is %s",
--
WARNING: quoted string split across lines
#353: FILE: /tmp/f1-7663/zebra_wrap_script.c:353:
+					zlog_err("(%d)ITEM Obtained "
+						 "for %s is %s",

CLANG Static Analyzer Summary

  • Github Pull Request 2025, comparing to Git base SHA 3971233

No Changes in Static Analysis warnings compared to base

6 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-3486/artifact/shared/static_analysis/index.html

@LabN-CI
Copy link
Collaborator

LabN-CI commented Apr 30, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/2025 17e3736
Date 04/30/2018
Start 08:35:29
Finish 08:58:29
Run-Time 23:00
Total 1813
Pass 1813
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-04-30-08:35:29.txt
Log autoscript-2018-04-30-08:36:19.log.bz2

For details, please contact louberger

@qlyoung
Copy link
Member

qlyoung commented Apr 30, 2018

@pguibert6WIND

For point 3, security, I say that zebra may be open a secuty hole, but I am sure the administrator has a full set of tools to manage not only FRR but the environment around. There are a lot of linux tools that permit customize security, by taking into account not only FRR but also some external scripting that may be called.

This is the wrong attitude to have. It is not acceptable to knowingly introduce security issues in software simply because external mitigations / permission systems exist. If e.g. Apache were to take this stance and respond to security issues with something like "Well, you should just run Apache in an isolated VM with strict SELinux policies" then Apache would die a swift and irreversible death. In short, from a security standpoint, I expect every program in this suite to be as bulletproof and idiot-proof as we can possibly make them and this PR runs totally contrary to that objective.

See also:
https://netfilter.org/documentation/FAQ/netfilter-faq-4.html#ss4.5

While they do claim that "it is recommended to [...] use system()" IMO this is not an acceptable answer in FRR. As naïve as it is to suggest, your efforts might be best spent on contributing an API to netfilter / iptables rather than parsing fragile text output here.

pguibert6WIND added a commit to pguibert6WIND/frr that referenced this pull request Feb 7, 2024
When a BGP flowspec peering stops, the BGP RIB entries for IPv6
flowspec entries are removed, but not the ZEBRA RIB IPv6 entries.

Actually, when calling bgp_zebra_withdraw() function call, only
the AFI_IP parameter is passed to the bgp_pbr_update_entry() function
in charge of the Flowspec add/delete in zebra. Fix this by passing
the AFI parameter to the bgp_zebra_withdraw() function.

Note that using topotest does not show up the problem as the
flowspec driver code is not present and was refused. Without that,
routes are not installed, and can not be uninstalled.

Fixes: 529efa2 ("bgpd: allow flowspec entries to be announced to zebra")
Link: FRRouting#2025

Signed-off-by: Philippe Guibert <[email protected]>
cscarpitta pushed a commit to cscarpitta/frr that referenced this pull request Feb 9, 2024
When a BGP flowspec peering stops, the BGP RIB entries for IPv6
flowspec entries are removed, but not the ZEBRA RIB IPv6 entries.

Actually, when calling bgp_zebra_withdraw() function call, only
the AFI_IP parameter is passed to the bgp_pbr_update_entry() function
in charge of the Flowspec add/delete in zebra. Fix this by passing
the AFI parameter to the bgp_zebra_withdraw() function.

Note that using topotest does not show up the problem as the
flowspec driver code is not present and was refused. Without that,
routes are not installed, and can not be uninstalled.

Fixes: 529efa2 ("bgpd: allow flowspec entries to be announced to zebra")
Link: FRRouting#2025

Signed-off-by: Philippe Guibert <[email protected]>
donaldsharp pushed a commit to donaldsharp/frr that referenced this pull request Apr 22, 2024
When a BGP flowspec peering stops, the BGP RIB entries for IPv6
flowspec entries are removed, but not the ZEBRA RIB IPv6 entries.

Actually, when calling bgp_zebra_withdraw() function call, only
the AFI_IP parameter is passed to the bgp_pbr_update_entry() function
in charge of the Flowspec add/delete in zebra. Fix this by passing
the AFI parameter to the bgp_zebra_withdraw() function.

Note that using topotest does not show up the problem as the
flowspec driver code is not present and was refused. Without that,
routes are not installed, and can not be uninstalled.

Fixes: 529efa2 ("bgpd: allow flowspec entries to be announced to zebra")
Link: FRRouting#2025

Signed-off-by: Philippe Guibert <[email protected]>
donaldsharp pushed a commit to donaldsharp/frr that referenced this pull request Nov 26, 2024
When a BGP flowspec peering stops, the BGP RIB entries for IPv6
flowspec entries are removed, but not the ZEBRA RIB IPv6 entries.

Actually, when calling bgp_zebra_withdraw() function call, only
the AFI_IP parameter is passed to the bgp_pbr_update_entry() function
in charge of the Flowspec add/delete in zebra. Fix this by passing
the AFI parameter to the bgp_zebra_withdraw() function.

Note that using topotest does not show up the problem as the
flowspec driver code is not present and was refused. Without that,
routes are not installed, and can not be uninstalled.

Fixes: 529efa2 ("bgpd: allow flowspec entries to be announced to zebra")
Link: FRRouting#2025

Signed-off-by: Philippe Guibert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants