From bce2638e7b108d5f9d908dca3bec0982642ce416 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Tue, 1 Mar 2011 08:58:26 -0800 Subject: [PATCH] FromHost: Check existence of inet_ctl_sock_create, not inet_ioctl. Earlier Linux versions have inet_ioctl but not inet_ctl_sock_create. Signed-off-by: Eddie Kohler --- config-linuxmodule.h.in | 3 +++ configure | 16 ++++++++++++++++ configure.in | 8 ++++++++ elements/linuxmodule/fromhost.cc | 8 ++++---- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/config-linuxmodule.h.in b/config-linuxmodule.h.in index dbef4e279f..204297669e 100644 --- a/config-linuxmodule.h.in +++ b/config-linuxmodule.h.in @@ -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 diff --git a/configure b/configure index e870898eb6..e2573fc3f4 100755 --- a/configure +++ b/configure @@ -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 " >&5 $as_echo_n "checking for ... " >&6; } if test "${ac_cv_linux_ktime_h+set}" = set; then : diff --git a/configure.in b/configure.in index 55b53d4db5..06976e6509 100644 --- a/configure.in +++ b/configure.in @@ -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 , 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 diff --git a/elements/linuxmodule/fromhost.cc b/elements/linuxmodule/fromhost.cc index bf3c0fac34..eeaed4f05f 100644 --- a/elements/linuxmodule/fromhost.cc +++ b/elements/linuxmodule/fromhost.cc @@ -45,7 +45,7 @@ CLICK_CXX_PROTECT CLICK_CXX_UNPROTECT #include -#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)) @@ -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) { @@ -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