diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 693513e7..fc70e306 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,263 +1,263 @@
#!/bin/sh
# Print a version string.
scriptversion=2018-08-31.20; # UTC
-# Copyright (C) 2018 Red Hat, Inc.
+# Copyright (C) 2012-2018 Red Hat, Inc.
# Copyright (C) 2007-2016 Free Software Foundation, Inc.
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program 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. If not, see .
# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
# It may be run two ways:
# - from a git repository in which the "git describe" command below
# produces useful output (thus requiring at least one signed tag)
# - from a non-git-repo directory containing a .tarball-version file, which
# presumes this script is invoked like "./git-version-gen .tarball-version".
# In order to use intra-version strings in your project, you will need two
# separate generated version string files:
#
# .tarball-version - present only in a distribution tarball, and not in
# a checked-out repository. Created with contents that were learned at
# the last time autoconf was run, and used by git-version-gen. Must not
# be present in either $(srcdir) or $(builddir) for git-version-gen to
# give accurate answers during normal development with a checked out tree,
# but must be present in a tarball when there is no version control system.
# Therefore, it cannot be used in any dependencies. GNUmakefile has
# hooks to force a reconfigure at distribution time to get the value
# correct, without penalizing normal development with extra reconfigures.
#
# .version - present in a checked-out repository and in a distribution
# tarball. Usable in dependencies, particularly for files that don't
# want to depend on config.h but do want to track version changes.
# Delete this file prior to any autoconf run where you want to rebuild
# files to pick up a version string change; and leave it stale to
# minimize rebuild time after unrelated changes to configure sources.
#
# As with any generated file in a VC'd directory, you should add
# /.version to .gitignore, so that you don't accidentally commit it.
# .tarball-version is never generated in a VC'd directory, so needn't
# be listed there.
#
# In order to use git archive versions another two files has to be presented:
#
# .gitarchive-version - present in checked-out repository and git
# archive tarball, but not in the distribution tarball. Used as a last
# option for version. File must contain special string $Format:%d$,
# which is substitued by git on archive operation.
#
# .gitattributes - present in checked-out repository and git archive
# tarball, but not in the distribution tarball. Must set export-subst
# attribute for .gitarchive-version file.
#
# Use the following line in your configure.ac, so that $(VERSION) will
# automatically be up-to-date each time configure is run (and note that
# since configure.ac no longer includes a version string, Makefile rules
# should not depend on configure.ac for version updates).
#
# AC_INIT([GNU project],
# m4_esyscmd([build-aux/git-version-gen .tarball-version]),
# [bug-project@example])
#
# Then use the following lines in your Makefile.am, so that .version
# will be present for dependencies, and so that .version and
# .tarball-version will exist in distribution tarballs.
#
# EXTRA_DIST = $(top_srcdir)/.version
# BUILT_SOURCES = $(top_srcdir)/.version
# $(top_srcdir)/.version:
# echo $(VERSION) > $@-t && mv $@-t $@
# dist-hook:
# echo $(VERSION) > $(distdir)/.tarball-version
me=$0
version="git-version-gen $scriptversion
Copyright 2011 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
usage="\
Usage: $me [OPTION]... \$srcdir/.tarball-version [\$srcdir/.gitarchive-version] [TAG-NORMALIZATION-SED-SCRIPT]
Print a version string.
Options:
--prefix PREFIX prefix of git tags (default 'v')
--fallback VERSION
fallback version to use if \"git --version\" fails
--help display this help and exit
--version output version information and exit
Running without arguments will suffice in most cases."
prefix=v
fallback=
while test $# -gt 0; do
case $1 in
--help) echo "$usage"; exit 0;;
--version) echo "$version"; exit 0;;
--prefix) shift; prefix="$1";;
--fallback) shift; fallback="$1";;
-*)
echo "$0: Unknown option '$1'." >&2
echo "$0: Try '--help' for more information." >&2
exit 1;;
*)
if test "x$tarball_version_file" = x; then
tarball_version_file="$1"
elif test "x$gitarchive_version_file" = x; then
gitarchive_version_file="$1"
elif test "x$tag_sed_script" = x; then
tag_sed_script="$1"
else
echo "$0: extra non-option argument '$1'." >&2
exit 1
fi;;
esac
shift
done
if test "x$tarball_version_file" = x; then
echo "$usage"
exit 1
fi
tag_sed_script="${tag_sed_script:-s/x/x/}"
nl='
'
# Avoid meddling by environment variable of the same name.
v=
v_from_git=
# First see if there is a tarball-only version file.
# then try "git describe", then default.
if test -f $tarball_version_file
then
v=`cat $tarball_version_file` || v=
case $v in
*$nl*) v= ;; # reject multi-line output
[0-9]*) ;;
*) v= ;;
esac
test "x$v" = x \
&& echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2
fi
if test "x$v" != x
then
: # use $v
# Otherwise, if there is at least one git commit involving the working
# directory, and "git describe" output looks sensible, use that to
# derive a version string.
elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
&& v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \
|| git describe --abbrev=4 HEAD 2>/dev/null` \
&& v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
&& case $v in
$prefix[0-9]*) ;;
*) (exit 1) ;;
esac
then
# Is this a new git that lists number of commits since the last
# tag or the previous older version that did not?
# Newer: v6.10-77-g0f8faeb
# Older: v6.10-g0f8faeb
case $v in
*-*-*) : git describe is okay three part flavor ;;
*-*)
: git describe is older two part flavor
# Recreate the number of commits and rewrite such that the
# result is the same as if we were using the newer version
# of git describe.
vtag=`echo "$v" | sed 's/-.*//'`
commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \
|| { commit_list=failed;
echo "$0: WARNING: git rev-list failed" 1>&2; }
numcommits=`echo "$commit_list" | wc -l`
v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`;
test "$commit_list" = failed && v=UNKNOWN
;;
esac
# Change the first '-' to a '.', so version-comparing tools work properly.
# Remove the "g" in git describe's output string, to save a byte.
v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
v_from_git=1
elif test "x$fallback" = x || git --version >/dev/null 2>&1; then
if test -f $gitarchive_version_file
then
v=`sed "s/^.*tag: \($prefix[0-9)][^,)]*\).*\$/\1/" $gitarchive_version_file \
| sed "$tag_sed_script"` || exit 1
case $v in
*$nl*) v= ;; # reject multi-line output
$prefix[0-9]*) ;;
*) v= ;;
esac
test -z "$v" \
&& echo "$0: WARNING: $gitarchive_version_file doesn't contain valid version tag" 1>&2 \
&& v=UNKNOWN
else
v=UNKNOWN
fi
else
v=$fallback
fi
if test "x$fallback" = x -a "$v" = "UNKNOWN"
then
echo "$0: ERROR: Can't find valid version. Please use valid git repository," \
"released tarball or version tagged archive" 1>&2
exit 1
fi
v=`echo "$v" |sed "s/^$prefix//"`
# Test whether to append the "-dirty" suffix only if the version
# string we're using came from git. I.e., skip the test if it's "UNKNOWN"
# or if it came from .tarball-version.
if test "x$v_from_git" != x; then
# Don't declare a version "dirty" merely because a time stamp has changed.
git update-index --refresh > /dev/null 2>&1
dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty=
case "$dirty" in
'') ;;
*) # Append the suffix only if there isn't one already.
case $v in
*-dirty) ;;
*) v="$v-dirty" ;;
esac ;;
esac
fi
# Omit the trailing newline, so that m4_esyscmd can use the result directly.
printf %s "$v"
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/build-aux/update-copyright.sh b/build-aux/update-copyright.sh
index babb25a3..fd50f8ea 100755
--- a/build-aux/update-copyright.sh
+++ b/build-aux/update-copyright.sh
@@ -1,29 +1,29 @@
#!/bin/sh
#
# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
# script to update copyright dates across the tree
enddate=$(date +%Y)
-input=$(grep -ril -e "Copyright.*Red Hat" |grep -v .swp |grep -v update-copyright)
+input=$(grep -ril -e "Copyright.*Red Hat" |grep -v .swp |grep -v update-copyright |grep -v doxyxml.c)
for i in $input; do
startdate=$(git log --follow "$i" | grep ^Date: | tail -n 1 | awk '{print $6}')
if [ "$startdate" != "$enddate" ]; then
sed -i -e 's#Copyright (C).*Red Hat#Copyright (C) '$startdate'-'$enddate' Red Hat#g' $i
else
sed -i -e 's#Copyright (C).*Red Hat#Copyright (C) '$startdate' Red Hat#g' $i
fi
done
input=$(find . -type f |grep -v ".git")
for i in $input; do
if [ -z "$(grep -i "Copyright" $i)" ]; then
echo "WARNING: $i appears to be missing Copyright information"
fi
done
diff --git a/libnozzle/internals.c b/libnozzle/internals.c
index 437fe4a2..c294eb4e 100644
--- a/libnozzle/internals.c
+++ b/libnozzle/internals.c
@@ -1,185 +1,185 @@
/*
- * Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "libnozzle.h"
#include "internals.h"
static int read_pipe(int fd, char **file, size_t *length)
{
char buf[4096];
int n;
int done = 0;
*file = NULL;
*length = 0;
memset(buf, 0, sizeof(buf));
while (!done) {
n = read(fd, buf, sizeof(buf));
if (n < 0) {
if (errno == EINTR)
continue;
if (*file)
free(*file);
return n;
}
if (n == 0 && (!*length))
return 0;
if (n == 0)
done = 1;
if (*file)
*file = realloc(*file, (*length) + n + done);
else
*file = malloc(n + done);
if (!*file)
return -1;
memmove((*file) + (*length), buf, n);
*length += (done + n);
}
/* Null terminator */
(*file)[(*length) - 1] = 0;
return 0;
}
int execute_bin_sh_command(const char *command, char **error_string)
{
pid_t pid;
int status, err = 0;
int fd[2];
size_t size = 0;
if ((command == NULL) || (!error_string)) {
errno = EINVAL;
return -1;
}
*error_string = NULL;
err = pipe(fd);
if (err)
goto out_clean;
pid = fork();
if (pid < 0) {
err = pid;
goto out_clean;
}
if (pid) { /* parent */
close(fd[1]);
err = read_pipe(fd[0], error_string, &size);
if (err)
goto out_clean0;
waitpid(pid, &status, 0);
if (!WIFEXITED(status)) {
err = -1;
goto out_clean0;
}
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
err = WEXITSTATUS(status);
goto out_clean0;
}
goto out_clean0;
} else { /* child */
close(0);
close(1);
close(2);
close(fd[0]);
dup2(fd[1], 1);
dup2(fd[1], 2);
close(fd[1]);
execlp("/bin/sh", "/bin/sh", "-c", command, NULL);
exit(EXIT_FAILURE);
}
out_clean:
close(fd[1]);
out_clean0:
close(fd[0]);
return err;
}
char *generate_v4_broadcast(const char *ipaddr, const char *prefix)
{
int prefix_len;
struct in_addr mask;
struct in_addr broadcast;
struct in_addr address;
prefix_len = atoi(prefix);
if ((prefix_len > 32) || (prefix_len < 0))
return NULL;
if (inet_pton(AF_INET, ipaddr, &address) <= 0)
return NULL;
mask.s_addr = htonl(~((1 << (32 - prefix_len)) - 1));
memset(&broadcast, 0, sizeof(broadcast));
broadcast.s_addr = (address.s_addr & mask.s_addr) | ~mask.s_addr;
return strdup(inet_ntoa(broadcast));
}
int find_ip(nozzle_t nozzle,
const char *ipaddr, const char *prefix,
struct nozzle_ip **ip, struct nozzle_ip **ip_prev)
{
struct nozzle_ip *local_ip, *local_ip_prev;
int found = 0;
local_ip = local_ip_prev = nozzle->ip;
while(local_ip) {
if ((!strcmp(local_ip->ipaddr, ipaddr)) && (!strcmp(local_ip->prefix, prefix))) {
found = 1;
break;
}
local_ip_prev = local_ip;
local_ip = local_ip->next;
}
if (found) {
*ip = local_ip;
*ip_prev = local_ip_prev;
}
return found;
}
diff --git a/libnozzle/internals.h b/libnozzle/internals.h
index c05d56de..56ee49ad 100644
--- a/libnozzle/internals.h
+++ b/libnozzle/internals.h
@@ -1,78 +1,78 @@
/*
- * Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#ifndef __NOZZLE_INTERNALS_H__
#define __NOZZLE_INTERNALS_H__
#include "config.h"
#ifdef KNET_LINUX
#include
#endif
#include
struct nozzle_lib_config {
struct nozzle_iface *head;
int ioctlfd;
#ifdef KNET_LINUX
struct nl_sock *nlsock;
#endif
};
#define IPADDR_CHAR_MAX 128
#define PREFIX_CHAR_MAX 4
struct nozzle_ip {
char ipaddr[IPADDR_CHAR_MAX + 1];
char prefix[PREFIX_CHAR_MAX + 1];
int domain; /* AF_INET or AF_INET6 */
struct nozzle_ip *next;
};
#define MACADDR_CHAR_MAX 18
/*
* 11 = post-down.d
* 1 = /
*/
#define UPDOWN_PATH_MAX PATH_MAX - 11 - 1 - IFNAMSIZ
struct nozzle_iface {
char name[IFNAMSIZ]; /* interface name */
int fd; /* interface fd */
int up; /* interface status 0 is down, 1 is up */
/*
* extra data
*/
struct nozzle_ip *ip; /* configured ip addresses */
/*
* default MAC address assigned by the kernel at creation time
*/
char default_mac[MACADDR_CHAR_MAX + 1];
int default_mtu; /* MTU assigned by the kernel at creation time */
int current_mtu; /* MTU configured by libnozzle user */
int hasupdown; /* interface has up/down path to scripts configured */
char updownpath[UPDOWN_PATH_MAX]; /* path to up/down scripts if configured */
struct nozzle_iface *next;
};
#define ifname ifr.ifr_name
int execute_bin_sh_command(const char *command, char **error_string);
int find_ip(nozzle_t nozzle,
const char *ipaddr, const char *prefix,
struct nozzle_ip **ip, struct nozzle_ip **ip_prev);
char *generate_v4_broadcast(const char *ipaddr, const char *prefix);
#endif
diff --git a/libnozzle/tests/Makefile.am b/libnozzle/tests/Makefile.am
index 78419d1c..5cbb788a 100644
--- a/libnozzle/tests/Makefile.am
+++ b/libnozzle/tests/Makefile.am
@@ -1,40 +1,40 @@
#
-# Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk
EXTRA_DIST = tap_updown_bad tap_updown_good api-test-coverage
if BUILD_LIBNOZZLE
check_PROGRAMS = nozzle_test
TESTS = $(check_PROGRAMS)
noinst_PROGRAMS = $(check_PROGRAMS)
check-local: check-api-test-coverage
check-api-test-coverage:
chmod u+x $(top_srcdir)/libnozzle/tests/api-test-coverage
$(top_srcdir)/libnozzle/tests/api-test-coverage $(top_srcdir) $(top_builddir)
nozzle_test_SOURCES = nozzle_test.c \
../internals.c
nozzle_test_CPPFLAGS = -I$(top_srcdir)/libnozzle \
-DABSBUILDDIR=\"$(abs_builddir)\"
nozzle_test_CFLAGS = $(PTHREAD_CFLAGS) $(libnl_CFLAGS)
nozzle_test_LDFLAGS = $(top_builddir)/libnozzle/libnozzle.la \
$(PTHREAD_LIBS) $(libnl_LIBS)
endif
diff --git a/libnozzle/tests/nozzle_test.c b/libnozzle/tests/nozzle_test.c
index a9ca16ac..cae35eaf 100644
--- a/libnozzle/tests/nozzle_test.c
+++ b/libnozzle/tests/nozzle_test.c
@@ -1,1275 +1,1275 @@
/*
- * Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef KNET_LINUX
#include
#include
#endif
#ifdef KNET_BSD
#include
#endif
#include "libnozzle.h"
#include "internals.h"
char testipv4_1[1024];
char testipv4_2[1024];
char testipv6_1[1024];
char testipv6_2[1024];
/*
* use this one to randomize knet interface name
* for named creation test
*/
uint8_t randombyte = 0;
static int is_if_in_system(char *name)
{
struct ifaddrs *ifap = NULL;
struct ifaddrs *ifa;
int found = 0;
if (getifaddrs(&ifap) < 0) {
printf("Unable to get interface list.\n");
return -1;
}
ifa = ifap;
while (ifa) {
if (!strncmp(name, ifa->ifa_name, IFNAMSIZ)) {
found = 1;
break;
}
ifa=ifa->ifa_next;
}
freeifaddrs(ifap);
return found;
}
static int test_iface(char *name, size_t size, const char *updownpath)
{
nozzle_t nozzle;
nozzle=nozzle_open(name, size, updownpath);
if (!nozzle) {
printf("Unable to open knet.\n");
return -1;
}
printf("Created interface: %s\n", name);
if (is_if_in_system(name) > 0) {
printf("Found interface %s on the system\n", name);
} else {
printf("Unable to find interface %s on the system\n", name);
}
if (!nozzle_get_handle_by_name(name)) {
printf("Unable to find interface %s in nozzle db\n", name);
} else {
printf("Found interface %s in nozzle db\n", name);
}
nozzle_close(nozzle);
if (is_if_in_system(name) == 0)
printf("Successfully removed interface %s from the system\n", name);
return 0;
}
static int check_nozzle_open_close(void)
{
char device_name[2*IFNAMSIZ];
char fakepath[PATH_MAX];
size_t size = IFNAMSIZ;
memset(device_name, 0, sizeof(device_name));
printf("Creating random nozzle interface:\n");
if (test_iface(device_name, size, NULL) < 0) {
printf("Unable to create random interface\n");
return -1;
}
#ifdef KNET_LINUX
printf("Creating kronostest%u nozzle interface:\n", randombyte);
snprintf(device_name, IFNAMSIZ, "kronostest%u", randombyte);
if (test_iface(device_name, size, NULL) < 0) {
printf("Unable to create kronostest%u interface\n", randombyte);
return -1;
}
#endif
#ifdef KNET_BSD
printf("Creating tap%u nozzle interface:\n", randombyte);
snprintf(device_name, IFNAMSIZ, "tap%u", randombyte);
if (test_iface(device_name, size, NULL) < 0) {
printf("Unable to create tap%u interface\n", randombyte);
return -1;
}
printf("Creating kronostest%u nozzle interface:\n", randombyte);
snprintf(device_name, IFNAMSIZ, "kronostest%u", randombyte);
if (test_iface(device_name, size, NULL) == 0) {
printf("BSD should not accept kronostest%u interface\n", randombyte);
return -1;
}
#endif
printf("Testing ERROR conditions\n");
printf("Testing dev == NULL\n");
errno=0;
if ((test_iface(NULL, size, NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_open sanity checks\n");
return -1;
}
printf("Testing size < IFNAMSIZ\n");
errno=0;
if ((test_iface(device_name, 1, NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_open sanity checks\n");
return -1;
}
printf("Testing device_name size > IFNAMSIZ\n");
errno=0;
strcpy(device_name, "abcdefghilmnopqrstuvwz");
if ((test_iface(device_name, IFNAMSIZ, NULL) >= 0) || (errno != E2BIG)) {
printf("Something is wrong in nozzle_open sanity checks\n");
return -1;
}
printf("Testing updown path != abs\n");
errno=0;
memset(device_name, 0, IFNAMSIZ);
if ((test_iface(device_name, IFNAMSIZ, "foo") >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_open sanity checks\n");
return -1;
}
memset(fakepath, 0, PATH_MAX);
memset(fakepath, '/', PATH_MAX - 2);
printf("Testing updown path > PATH_MAX\n");
errno=0;
memset(device_name, 0, IFNAMSIZ);
if ((test_iface(device_name, IFNAMSIZ, fakepath) >= 0) || (errno != E2BIG)) {
printf("Something is wrong in nozzle_open sanity checks\n");
return -1;
}
return 0;
}
static int check_knet_multi_eth(void)
{
char device_name1[IFNAMSIZ];
char device_name2[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle1 = NULL;
nozzle_t nozzle2 = NULL;
printf("Testing multiple knet interface instances\n");
memset(device_name1, 0, size);
memset(device_name2, 0, size);
nozzle1 = nozzle_open(device_name1, size, NULL);
if (!nozzle1) {
printf("Unable to init %s\n", device_name1);
err = -1;
goto out_clean;
}
if (is_if_in_system(device_name1) > 0) {
printf("Found interface %s on the system\n", device_name1);
} else {
printf("Unable to find interface %s on the system\n", device_name1);
}
nozzle2 = nozzle_open(device_name2, size, NULL);
if (!nozzle2) {
printf("Unable to init %s\n", device_name2);
err = -1;
goto out_clean;
}
if (is_if_in_system(device_name2) > 0) {
printf("Found interface %s on the system\n", device_name2);
} else {
printf("Unable to find interface %s on the system\n", device_name2);
}
if (nozzle1) {
nozzle_close(nozzle1);
}
if (nozzle2) {
nozzle_close(nozzle2);
}
printf("Testing error conditions\n");
printf("Open same device twice\n");
memset(device_name1, 0, size);
nozzle1 = nozzle_open(device_name1, size, NULL);
if (!nozzle1) {
printf("Unable to init %s\n", device_name1);
err = -1;
goto out_clean;
}
if (is_if_in_system(device_name1) > 0) {
printf("Found interface %s on the system\n", device_name1);
} else {
printf("Unable to find interface %s on the system\n", device_name1);
}
nozzle2 = nozzle_open(device_name1, size, NULL);
if (nozzle2) {
printf("We were able to init 2 interfaces with the same name!\n");
err = -1;
goto out_clean;
}
out_clean:
if (nozzle1) {
nozzle_close(nozzle1);
}
if (nozzle2) {
nozzle_close(nozzle2);
}
return err;
}
static int check_knet_mtu(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
int current_mtu = 0;
int expected_mtu = 1500;
printf("Testing get/set MTU\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Comparing default MTU\n");
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected default [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Setting MTU to 9000\n");
expected_mtu = 9000;
if (nozzle_set_mtu(nozzle, expected_mtu) < 0) {
printf("Unable to set MTU to %d\n", expected_mtu);
err = -1;
goto out_clean;
}
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected value [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Passing empty struct to get_mtu\n");
if (nozzle_get_mtu(NULL) > 0) {
printf("Something is wrong in nozzle_get_mtu sanity checks\n");
err = -1;
goto out_clean;
}
printf("Passing empty struct to set_mtu\n");
if (nozzle_set_mtu(NULL, 1500) == 0) {
printf("Something is wrong in nozzle_set_mtu sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
static int check_knet_mtu_ipv6(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
char verifycmd[1024];
int err=0;
nozzle_t nozzle;
char *error_string = NULL;
printf("Testing get/set MTU with IPv6 address\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Adding ip: %s/64\n", testipv6_1);
err = nozzle_add_ip(nozzle, testipv6_1, "64");
if (err) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Setting MTU to 1200\n");
if (nozzle_set_mtu(nozzle, 1200) < 0) {
printf("Unable to set MTU to 1200\n");
err = -1;
goto out_clean;
}
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
#ifdef KNET_LINUX
if (!err) {
#endif
#ifdef KNET_BSD
if (err) {
#endif
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Adding ip: %s/64\n", testipv6_2);
err = nozzle_add_ip(nozzle, testipv6_2, "64");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_2);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_2);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Restoring MTU to default\n");
if (nozzle_reset_mtu(nozzle) < 0) {
printf("Unable to reset mtu\n");
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_2);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_2);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
static int check_knet_mac(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
char *current_mac = NULL, *temp_mac = NULL, *err_mac = NULL;
struct ether_addr *cur_mac, *tmp_mac;
printf("Testing get/set MAC\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Get current MAC\n");
if (nozzle_get_mac(nozzle, ¤t_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
printf("Current MAC: %s\n", current_mac);
printf("Setting MAC: 00:01:01:01:01:01\n");
if (nozzle_set_mac(nozzle, "00:01:01:01:01:01") < 0) {
printf("Unable to set current MAC address.\n");
err = -1;
goto out_clean;
}
if (nozzle_get_mac(nozzle, &temp_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
printf("Current MAC: %s\n", temp_mac);
cur_mac = ether_aton(current_mac);
tmp_mac = ether_aton(temp_mac);
printf("Comparing MAC addresses\n");
if (memcmp(cur_mac, tmp_mac, sizeof(struct ether_addr))) {
printf("Mac addresses are not the same?!\n");
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Pass NULL to get_mac (pass1)\n");
errno = 0;
if ((nozzle_get_mac(NULL, &err_mac) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_get_mac sanity checks\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to get_mac (pass2)\n");
errno = 0;
if ((nozzle_get_mac(nozzle, NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_get_mac sanity checks\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to set_mac (pass1)\n");
errno = 0;
if ((nozzle_set_mac(nozzle, NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_mac sanity checks\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to set_mac (pass2)\n");
errno = 0;
if ((nozzle_set_mac(NULL, err_mac) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_mac sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (err_mac) {
printf("Something managed to set err_mac!\n");
err = -1;
free(err_mac);
}
if (current_mac)
free(current_mac);
if (temp_mac)
free(temp_mac);
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
static int check_nozzle_execute_bin_sh_command(void)
{
int err = 0;
char command[4096];
char *error_string = NULL;
memset(command, 0, sizeof(command));
printf("Testing execute_bin_sh_command\n");
printf("command true\n");
err = execute_bin_sh_command("true", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to execute true ?!?!\n");
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("command false\n");
err = execute_bin_sh_command("false", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute false successfully?!?!\n");
err = -1;
goto out_clean;
}
printf("command that outputs to stdout (enforcing redirect)\n");
err = execute_bin_sh_command("grep -h 2>&1", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute grep -h successfully?!?\n");
err = -1;
goto out_clean;
}
printf("command that outputs to stderr\n");
err = execute_bin_sh_command("grep -h", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute grep -h successfully?!?\n");
err = -1;
goto out_clean;
}
printf("empty command\n");
err = execute_bin_sh_command(NULL, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute (nil) successfully?!?!\n");
err = -1;
goto out_clean;
}
printf("empty error\n");
err = execute_bin_sh_command("true", NULL);
if (!err) {
printf("Check EINVAL filter for no error_string!\n");
err = -1;
goto out_clean;
}
err = 0;
out_clean:
return err;
}
static int check_knet_up_down(void)
{
char verifycmd[1024];
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
char *error_string = NULL;
printf("Testing interface up/down\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Put the interface up\n");
err = nozzle_set_up(nozzle);
if (err < 0) {
printf("Unable to set interface up\n");
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q UP", nozzle->name);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q UP", nozzle->name);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err < 0) {
printf("Unable to verify inteface UP\n");
err = -1;
goto out_clean;
}
printf("Put the interface down\n");
err = nozzle_set_down(nozzle);
if (err < 0) {
printf("Unable to put the interface down\n");
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q UP", nozzle->name);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q UP", nozzle->name);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Unable to verify inteface DOWN\n");
err = -1;
goto out_clean;
}
nozzle_close(nozzle);
printf("Testing interface pre-up/up/down/post-down (exec errors)\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, ABSBUILDDIR "/nozzle_updown_bad");
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Put the interface up\n");
err = nozzle_run_updown(nozzle, NOZZLE_PREUP, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_PREUP error: %s\n", strerror(errno));
}
if (error_string) {
printf("preup output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
err = nozzle_set_up(nozzle);
if (err < 0) {
printf("Unable to put the interface up\n");
err = -1;
goto out_clean;
}
err = nozzle_run_updown(nozzle, NOZZLE_UP, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_UP error: %s\n", strerror(errno));
}
if (error_string) {
printf("up output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
printf("Put the interface down\n");
err = nozzle_run_updown(nozzle, NOZZLE_DOWN, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_DOWN error: %s\n", strerror(errno));
}
if (error_string) {
printf("down output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
err = nozzle_set_down(nozzle);
if (err < 0) {
printf("Unable to put the interface down\n");
err = -1;
goto out_clean;
}
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_POSTDOWN error: %s\n", strerror(errno));
}
if (error_string) {
printf("postdown output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
nozzle_close(nozzle);
printf("Testing interface pre-up/up/down/post-down\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, ABSBUILDDIR "/nozzle_updown_good");
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Put the interface up\n");
err = nozzle_run_updown(nozzle, NOZZLE_PREUP, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_PREUP error: %s\n", strerror(errno));
}
if (error_string) {
printf("preup output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
err = nozzle_set_up(nozzle);
if (err < 0) {
printf("Unable to put the interface up\n");
err = -1;
goto out_clean;
}
err = nozzle_run_updown(nozzle, NOZZLE_UP, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_UP error: %s\n", strerror(errno));
}
if (error_string) {
printf("up output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
printf("Put the interface down\n");
err = nozzle_run_updown(nozzle, NOZZLE_DOWN, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_DOWN error: %s\n", strerror(errno));
}
if (error_string) {
printf("down output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
err = nozzle_set_down(nozzle);
if (err < 0) {
printf("Unable to put the interface down\n");
err = -1;
goto out_clean;
}
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN, &error_string);
if (err) {
printf("nozzle_run_updown NOZZLE_POSTDOWN error: %s\n", strerror(errno));
}
if (error_string) {
printf("postdown output: %s\n", error_string);
free(error_string);
error_string = NULL;
}
nozzle_close(nozzle);
printf("Test ERROR conditions\n");
printf("Pass NULL to nozzle set_up\n");
err = 0;
errno = 0;
if ((nozzle_set_up(NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_up sanity checks\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to nozzle set_down\n");
errno = 0;
if ((nozzle_set_down(NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_down sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
nozzle_close(nozzle);
return err;
}
static int check_knet_close_leak(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
printf("Testing close leak (needs valgrind)\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Adding ip: %s/24\n", testipv4_1);
err = nozzle_add_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
printf("Adding ip: %s/24\n", testipv4_2);
err = nozzle_add_ip(nozzle, testipv4_2, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
out_clean:
nozzle_close(nozzle);
return err;
}
static int check_knet_set_del_ip(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
char verifycmd[1024];
int err=0;
nozzle_t nozzle;
char *ip_list = NULL;
int ip_list_entries = 0, i, offset = 0;
char *error_string = NULL;
printf("Testing interface add/remove ip\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Adding ip: %s/24\n", testipv4_1);
err = nozzle_add_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
printf("Adding ip: %s/24\n", testipv4_2);
err = nozzle_add_ip(nozzle, testipv4_2, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
printf("Adding duplicate ip: %s/24\n", testipv4_1);
err = nozzle_add_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to find IP address in libnozzle db\n");
err=-1;
goto out_clean;
}
printf("Checking ip: %s/24\n", testipv4_1);
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/24", nozzle->name, testipv4_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv4_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Get ip list from libnozzle:\n");
if (nozzle_get_ips(nozzle, &ip_list, &ip_list_entries) < 0) {
printf("Not enough mem?\n");
err=-1;
goto out_clean;
}
if (ip_list_entries != 2) {
printf("Didn't get enough ip back from libnozzle?\n");
err=-1;
goto out_clean;
}
for (i = 1; i <= ip_list_entries; i++) {
printf("Found IP %s %s in libnozzle db\n", ip_list + offset, ip_list + offset + strlen(ip_list + offset) + 1);
offset = offset + strlen(ip_list) + 1;
offset = offset + strlen(ip_list + offset) + 1;
}
free(ip_list);
printf("Deleting ip: %s/24\n", testipv4_1);
err = nozzle_del_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to delete IP address\n");
err=-1;
goto out_clean;
}
printf("Deleting ip: %s/24\n", testipv4_2);
err = nozzle_del_ip(nozzle, testipv4_2, "24");
if (err < 0) {
printf("Unable to delete IP address\n");
err=-1;
goto out_clean;
}
printf("Deleting again ip: %s/24\n", testipv4_1);
err = nozzle_del_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to delete IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/24", nozzle->name, testipv4_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv4_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Adding ip: %s/64\n", testipv6_1);
err = nozzle_add_ip(nozzle, testipv6_1, "64");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Deleting ip: %s/64\n", testipv6_1);
err = nozzle_del_ip(nozzle, testipv6_1, "64");
if (err) {
printf("Unable to delete IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
out_clean:
nozzle_close(nozzle);
return err;
}
static void make_local_ips(void)
{
pid_t mypid;
uint8_t *pid;
uint8_t i;
if (sizeof(pid_t) < 4) {
printf("pid_t is smaller than 4 bytes?\n");
exit(77);
}
memset(testipv4_1, 0, sizeof(testipv4_1));
memset(testipv4_2, 0, sizeof(testipv4_2));
memset(testipv6_1, 0, sizeof(testipv6_1));
memset(testipv6_2, 0, sizeof(testipv6_2));
mypid = getpid();
pid = (uint8_t *)&mypid;
for (i = 0; i < sizeof(pid_t); i++) {
if (pid[i] == 0) {
pid[i] = 128;
}
}
randombyte = pid[1];
snprintf(testipv4_1,
sizeof(testipv4_1) - 1,
"127.%u.%u.%u",
pid[1],
pid[2],
pid[0]);
snprintf(testipv4_2,
sizeof(testipv4_2) - 1,
"127.%u.%d.%u",
pid[1],
pid[2]+1,
pid[0]);
snprintf(testipv6_1,
sizeof(testipv6_1) - 1,
"fd%x:%x%x::1",
pid[1],
pid[2],
pid[0]);
snprintf(testipv6_2,
sizeof(testipv6_2) - 1,
"fd%x:%x%x:1::1",
pid[1],
pid[2],
pid[0]);
}
int main(void)
{
if (geteuid() != 0) {
printf("This test requires root privileges\n");
exit(77);
}
make_local_ips();
if (check_nozzle_open_close() < 0)
return -1;
if (check_knet_multi_eth() < 0)
return -1;
if (check_knet_mtu() < 0)
return -1;
if (check_knet_mtu_ipv6() < 0)
return -1;
if (check_knet_mac() < 0)
return -1;
if (check_nozzle_execute_bin_sh_command() < 0)
return -1;
if (check_knet_up_down() < 0)
return -1;
if (check_knet_set_del_ip() < 0)
return -1;
if (check_knet_close_leak() < 0)
return -1;
return 0;
}
diff --git a/man/Doxyfile-nozzle.in b/man/Doxyfile-nozzle.in
index 3695ee48..0fb6f333 100644
--- a/man/Doxyfile-nozzle.in
+++ b/man/Doxyfile-nozzle.in
@@ -1,17 +1,17 @@
#
-# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto
# Christine Caulfield
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
PROJECT_NAME = @PACKAGE_NAME@
PROJECT_NUMBER = @PACKAGE_VERSION@
INPUT = @abs_top_srcdir@/libnozzle/libnozzle.h
XML_OUTPUT = @abs_builddir@/xml-nozzle
GENERATE_XML = YES
XML_PROGRAMLISTING = NO
AUTOLINK_SUPPORT = NO
GENERATE_HTML = NO
GENERATE_LATEX = NO