From: VMware, Inc <> Date: Thu, 17 Jun 2010 22:18:39 +0000 (-0700) Subject: VSOCK: remove compat_sk_filter X-Git-Tag: 2010.06.16-268169~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae6a9fdded9807b748a7e8d079b43e6d0d3cf4d7;p=thirdparty%2Fopen-vm-tools.git VSOCK: remove compat_sk_filter Filter interface has stabilized in the kernels that we do support so we can clean up our code a bit. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/linux/shared/autoconf/sk_filter.c b/open-vm-tools/modules/linux/shared/autoconf/sk_filter.c deleted file mode 100644 index f8bb288c3..000000000 --- a/open-vm-tools/modules/linux/shared/autoconf/sk_filter.c +++ /dev/null @@ -1,53 +0,0 @@ -/********************************************************* - * Copyright (C) 2007 VMware, Inc. All rights reserved. - * - * 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 version 2 and no 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, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *********************************************************/ - -/* - * Detect whether the old or new sk_filter() interface is used. This was - * changed in 2.4.21, but it's backported to some distro kernels. - * - * This test will fail to build on kernels with the new interface. - */ - -#include "compat_version.h" -#include "compat_autoconf.h" - -/* - * We'd restrict this test to 2.4.21 and earlier kernels, but Mandrake's - * enterprise-2.4.21-013mdk-9.1 appears to really be 2.4.20 with some patches, - * and not the patches we care about, so let's test on 2.4.21 kernels too. - */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 22) -#include -#include -#include -#include - -struct sk_buff test_skbuff; -struct sk_filter test_filter; - -int -sk_filter_test(void) -{ - struct sk_buff *skb = &test_skbuff; - struct sk_filter *filter = &test_filter; - - return sk_filter(skb, filter); -} -#else -#error "This test intentionally fails on 2.4.22 or newer kernels." -#endif diff --git a/open-vm-tools/modules/linux/shared/compat_sock.h b/open-vm-tools/modules/linux/shared/compat_sock.h index 00ea8cf60..581e61e8a 100644 --- a/open-vm-tools/modules/linux/shared/compat_sock.h +++ b/open-vm-tools/modules/linux/shared/compat_sock.h @@ -113,55 +113,20 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) # define compat_sock_owned_by_user(sk) sock_owned_by_user(sk) #endif -/* - * Up until 2.4.21 for the 2.4 series and 2.5.60 for the 2.5 series, - * sk_filter() calls were protected with CONFIG_FILTER. Wrapping our compat - * definition in a similar check allows us to build on those kernels. - * - */ -#ifdef CONFIG_FILTER -/* - * Unfortunately backports for certain kernels require the use of an autoconf - * program to check the interface for sk_filter(). - */ -# ifndef VMW_HAVE_NEW_SKFILTER -/* - * Up until 2.4.21 for the 2.4 series and 2.5.60 for the 2.5 series, - * callers to sk->filter were responsible for ensuring that the filter - * was not NULL. - * Additionally, the new version of sk_filter returns 0 or -EPERM on error - * while the old function returned 0 or 1. Return -EPERM here as well to - * be consistent. - */ -# define compat_sk_filter(sk, skb, needlock) \ - ({ \ - int rc = 0; \ - \ - if ((sk)->filter) { \ - rc = sk_filter(skb, (sk)->filter); \ - if (rc) { \ - rc = -EPERM; \ - } \ - } \ - \ - rc; \ - }) -# else -# define compat_sk_filter(sk, skb, needlock) sk_filter(sk, skb, needlock) -# endif -#else -# define compat_sk_filter(sk, skb, needlock) 0 -#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) + +#ifndef CONFIG_FILTER +# define sk_filter(sk, skb, needlock) 0 +#endif + /* Taken from 2.6.16's sock.h and modified for macro. */ # define compat_sk_receive_skb(sk, skb, nested) \ ({ \ int rc = NET_RX_SUCCESS; \ \ - if (compat_sk_filter(sk, skb, 0)) { \ + if (sk_filter(sk, skb, 0)) { \ kfree_skb(skb); \ - sock_put(sk); \ } else { \ skb->dev = NULL; \ bh_lock_sock(sk); \ @@ -171,9 +136,9 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) sk_add_backlog(sk, skb); \ } \ bh_unlock_sock(sk); \ - sock_put(sk); \ } \ \ + sock_put(sk); \ rc; \ }) #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) diff --git a/open-vm-tools/modules/linux/vsock/Makefile.kernel b/open-vm-tools/modules/linux/vsock/Makefile.kernel index 9776c55ee..1534cf08d 100644 --- a/open-vm-tools/modules/linux/vsock/Makefile.kernel +++ b/open-vm-tools/modules/linux/vsock/Makefile.kernel @@ -30,9 +30,6 @@ EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/epoll.c, -DVMW_HAVE_EPO EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/setnice.c, -DVMW_HAVE_SET_USER_NICE, ) EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/netcreate_num_params.c, -DVMW_NETCREATE_KERNARG, ) -# This test is inverted. -EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/sk_filter.c,, -DVMW_HAVE_NEW_SKFILTER ) - MODPOST_VMCI_SYMVERS := $(wildcard $(MODULEBUILDDIR)/VMwareVMCIModule.symvers)