test-netlink-manual.c revision b26fa1a2fbcfee7d03b0c8fd15ec3aa64ae70b9f
/***
This file is part of systemd.
Copyright 2014 Susant Sahani
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <libkmod.h>
#include <linux/if_tunnel.h>
#include "sd-netlink.h"
#include "macro.h"
#include "util.h"
static int load_module(const char *mod_name) {
int r;
if (!ctx) {
return -ENOMEM;
}
if (r < 0)
return -1;
kmod_list_foreach(l, list) {
if (r >= 0)
r = 0;
else
r = -1;
}
return r;
}
int r;
sd_netlink_message *m, *n;
/* skip test if module cannot be loaded */
r = load_module("ipip");
if(r < 0)
return EXIT_TEST_SKIP;
if(getuid() != 0)
return EXIT_TEST_SKIP;
/* IPIP tunnel */
assert_se(m);
assert_se(sd_netlink_message_close_container(m) >= 0);
assert_se(sd_netlink_message_close_container(m) >= 0);
r = load_module("sit");
if(r < 0)
return EXIT_TEST_SKIP;
/* sit */
assert_se(n);
assert_se(sd_netlink_message_close_container(n) >= 0);
assert_se(sd_netlink_message_close_container(n) >= 0);
return EXIT_SUCCESS;
}
int r;
r = test_tunnel_configure(rtnl);
return r;
}