Skip to content

Instantly share code, notes, and snippets.

@joestringer
Created September 9, 2015 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joestringer/63a4f3c2bd9d4f6ddac7 to your computer and use it in GitHub Desktop.
Save joestringer/63a4f3c2bd9d4f6ddac7 to your computer and use it in GitHub Desktop.
M4 to check for conntrack support and load modules
# CHECK_CONNTRACK()
#
# Perform requirements checks for running conntrack tests, and flush the
# kernel conntrack tables when the test is finished.
#
m4_define([CHECK_CONNTRACK],
[AT_SKIP_IF([test $HAVE_CONNTRACK = no])
AT_SKIP_IF([test $HAVE_PYTHON = no])
m4_foreach([mod], [[nf_conntrack_ipv4], [nf_conntrack_ipv6]],
[modprobe mod || echo "Module mod not loaded."
echo "loaded mod"
lsmod | grep nf_conn
on_exit "modprobe -q -r mod"
on_exit "echo 'attempting to unload mod'"])
on_exit 'conntrack -F'
]
)
@joestringer
Copy link
Author

on_exit bash function reads the rest of the line in as arguments, so the '])' to close m4_foreach() needs to be on its own line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment