Skip to content

Commit

Permalink
FromHost: Check existence of inet_ctl_sock_create, not inet_ioctl.
Browse files Browse the repository at this point in the history
Earlier Linux versions have inet_ioctl but not inet_ctl_sock_create.

Signed-off-by: Eddie Kohler <[email protected]>
  • Loading branch information
kohler committed Mar 1, 2011
1 parent b1aacc9 commit bce2638
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config-linuxmodule.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
/* Define if your Linux kernel has devinet_ioctl. */
#undef HAVE_LINUX_DEVINET_IOCTL

/* Define if your Linux kernel has inet_ctl_sock_create. */
#undef HAVE_LINUX_INET_CTL_SOCK_CREATE

/* Define if your Linux kernel has inet_ioctl. */
#undef HAVE_LINUX_INET_IOCTL

Expand Down
16 changes: 16 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -8870,6 +8870,22 @@ if test $ac_cv_linux_inet_ioctl = yes; then

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ctl_sock_create kernel symbol" >&5
$as_echo_n "checking for inet_ctl_sock_create kernel symbol... " >&6; }
if test "${ac_cv_linux_inet_ctl_sock_create+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if grep "__ksymtab_inet_ctl_sock_create" $linux_system_map >/dev/null 2>&1; then
ac_cv_linux_inet_ctl_sock_create=yes
else ac_cv_linux_inet_ctl_sock_create=no; fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linux_inet_ctl_sock_create" >&5
$as_echo "$ac_cv_linux_inet_ctl_sock_create" >&6; }
if test $ac_cv_linux_inet_ctl_sock_create = yes; then
$as_echo "#define HAVE_LINUX_INET_CTL_SOCK_CREATE 1" >>confdefs.h

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for <linux/ktime.h>" >&5
$as_echo_n "checking for <linux/ktime.h>... " >&6; }
if test "${ac_cv_linux_ktime_h+set}" = set; then :
Expand Down
8 changes: 8 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,14 @@ if test $ac_cv_linux_inet_ioctl = yes; then
AC_DEFINE(HAVE_LINUX_INET_IOCTL)
fi

AC_CACHE_CHECK(for inet_ctl_sock_create kernel symbol, ac_cv_linux_inet_ctl_sock_create,
[if grep "__ksymtab_inet_ctl_sock_create" $linux_system_map >/dev/null 2>&1; then
ac_cv_linux_inet_ctl_sock_create=yes
else ac_cv_linux_inet_ctl_sock_create=no; fi])
if test $ac_cv_linux_inet_ctl_sock_create = yes; then
AC_DEFINE(HAVE_LINUX_INET_CTL_SOCK_CREATE)
fi

AC_CACHE_CHECK(for <linux/ktime.h>, ac_cv_linux_ktime_h,
[if grep ktime_t `find_linuxpath include/linux/ktime.h` >/dev/null 2>&1; then
ac_cv_linux_ktime_h=yes
Expand Down
8 changes: 4 additions & 4 deletions elements/linuxmodule/fromhost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CLICK_CXX_PROTECT
CLICK_CXX_UNPROTECT
#include <click/cxxunprotect.h>

#if HAVE_LINUX_INET_IOCTL
#if HAVE_LINUX_INET_CTL_SOCK_CREATE
# define click_inet_ioctl(sock, dev, cmd, arg) inet_ioctl((sock), (cmd), (arg))
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) && CONFIG_NET_NS
# define click_inet_ioctl(sock, dev, cmd, arg) devinet_ioctl((dev)->nd_net, (cmd), (arg))
Expand Down Expand Up @@ -280,10 +280,10 @@ FromHost::set_device_addresses(ErrorHandler *errh)
}

if (_destaddr) {
#if HAVE_LINUX_DEVINET_IOCTL || HAVE_LINUX_INET_IOCTL
#if HAVE_LINUX_DEVINET_IOCTL || HAVE_LINUX_INET_CTL_SOCK_CREATE
sin->sin_family = AF_INET;
sin->sin_addr = _destaddr;
# if HAVE_LINUX_INET_IOCTL
# if HAVE_LINUX_INET_CTL_SOCK_CREATE
struct socket *sock = kmalloc(sizeof(struct socket), GFP_KERNEL);
sock->sk = 0;
if (res >= 0 && (res = inet_ctl_sock_create(&sock->sk, AF_INET, SOCK_RAW, IPPROTO_TCP, _dev->nd_net)) != 0) {
Expand All @@ -300,7 +300,7 @@ FromHost::set_device_addresses(ErrorHandler *errh)
if (res >= 0 && (res = click_inet_ioctl(sock, _dev, SIOCSIFNETMASK, &ifr)) < 0)
errh->error("error %d setting netmask for device '%s'", res, _devname.c_str());
set_fs(oldfs);
# if HAVE_LINUX_INET_IOCTL
# if HAVE_LINUX_INET_CTL_SOCK_CREATE
inet_ctl_sock_destroy(sock->sk);
kfree(sock);
# endif
Expand Down

0 comments on commit bce2638

Please sign in to comment.