Index: files/patch-bsdmodule__Makefile.in =================================================================== RCS file: files/patch-bsdmodule__Makefile.in diff -N files/patch-bsdmodule__Makefile.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-bsdmodule__Makefile.in 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,75 @@ +--- bsdmodule/Makefile.in.orig Wed Mar 22 19:52:08 2006 ++++ bsdmodule/Makefile.in Thu Feb 1 12:28:18 2007 +@@ -27,6 +27,20 @@ + INSTALL_DATA = @INSTALL@ -m 644 + mkinstalldirs = @top_srcdir@/mkinstalldirs + ++ifeq ($(V),1) ++ccompile = $(COMPILE) $(1) ++cxxcompile = $(CXXCOMPILE) $(1) ++else ++ccompile = @/bin/echo ' ' $(2) $< && $(COMPILE) $(1) ++cxxcompile = @/bin/echo ' ' $(2) $< && $(CXXCOMPILE) $(1) ++endif ++ ++quiet_cmd_cxxcompile = CXX $(quiet_modtag) $(subst $(obj)/,,$@) ++cmd_cxxcompile = $(CXXCOMPILE) -c -o $@ $< ++ ++quiet_cmd_ccompile = CC $(quiet_modtag) $(subst $(obj)/,,$@) ++cmd_ccompile = $(COMPILE) -c -o $@ $< ++ + .SUFFIXES: + .SUFFIXES: .S .c .cc .o .s .ii + +@@ -60,12 +74,12 @@ + driver.o \ + $(EXTRA_DRIVER_OBJS) + +-BSDMODULE_OBJS = config.o sched.o module.o \ ++BSDMODULE_OBJS = config.o sched.o module.o module_c.o \ + clickfs.o clickfs_vnops.o clickfs_tree.o clickfs_element.o + + EXTRA_DRIVER_OBJS = @EXTRA_DRIVER_OBJS@ + +-OBJS = setdef0.o $(GENERIC_OBJS) $(ELEMENT_OBJS) $(BSDMODULE_OBJS) elements.o setdef1.o ++OBJS = $(GENERIC_OBJS) $(ELEMENT_OBJS) $(BSDMODULE_OBJS) elements.o + + CPPFLAGS = @CPPFLAGS@ -DCLICK_BSDMODULE -DBSD_NETISRSCHED + CFLAGS = @CFLAGS_NDEBUG@ -g +@@ -90,7 +104,7 @@ + -include elements.mk + endif + +-click.ko: Makefile vnode_if.h $(OBJS) ++click.ko: Makefile vnode_if.h vnode_if_newproto.h vnode_if_typedef.h $(OBJS) + $(LD) -Bshareable -o click.ko $(OBJS) + + Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +@@ -108,11 +122,13 @@ + $(top_builddir)/click-buildtool elem2export < elements.conf > elements.cc + @rm -f elements.d + +-setdef0.c setdef1.c: module.o +- gensetdefs module.o +-vnode_if.h: $(freebsd_srcdir)/kern/vnode_if.pl $(freebsd_srcdir)/kern/vnode_if.src $(srcdir)/massage-vnode_if.pl +- $(PERL) $(freebsd_srcdir)/kern/vnode_if.pl -h $(freebsd_srcdir)/kern/vnode_if.src +- $(PERL) $(srcdir)/massage-vnode_if.pl vnode_if.h ++vnode_if.h: $(freebsd_srcdir)/kern/vnode_if.src ++ /usr/bin/awk -f $(freebsd_srcdir)/tools/vnode_if.awk $(freebsd_srcdir)/kern/vnode_if.src -h ++vnode_if_newproto.h: $(freebsd_srcdir)/kern/vnode_if.src ++ /usr/bin/awk -f $(freebsd_srcdir)/tools/vnode_if.awk $(freebsd_srcdir)/kern/vnode_if.src -p ++vnode_if_typedef.h: $(freebsd_srcdir)/kern/vnode_if.src ++ /usr/bin/awk -f $(freebsd_srcdir)/tools/vnode_if.awk $(freebsd_srcdir)/kern/vnode_if.src -q ++ + + DEPFILES := $(wildcard *.d) + ifneq ($(DEPFILES),) +@@ -129,7 +145,7 @@ + + clean: + -rm -f *.d *.o click.ko elements.mk elements.cc elements.conf \ +- vnode_if.h vnode_if.h~ setdef0.c setdef1.c setdefs.h ++ vnode_if.h vnode_if_newproto.h vnode_if_typedef.h + distclean: clean + -rm -f Makefile + Index: files/patch-bsdmodule__clickfs.cc =================================================================== RCS file: files/patch-bsdmodule__clickfs.cc diff -N files/patch-bsdmodule__clickfs.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-bsdmodule__clickfs.cc 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,105 @@ +--- bsdmodule/clickfs.cc.orig Thu Feb 1 11:03:21 2007 ++++ bsdmodule/clickfs.cc Fri Oct 13 04:19:23 2006 +@@ -29,16 +29,13 @@ + + #include + +-extern vop_t **clickfs_root_vnops; +-extern struct vnodeopv_desc clickfs_vnodeop_opv_desc; +- + struct clickfs_mount { + struct vnode *click_root; + }; + + static int + clickfs_mount(struct mount *mp, char *user_path, caddr_t data, +- struct nameidata *ndp, struct proc *p) ++ struct nameidata *ndp, struct thread *td) + { + char path[MAXPATHLEN]; + size_t count; +@@ -82,13 +79,7 @@ + } + + static int +-clickfs_start(struct mount *mp, int flags, struct proc *p) +-{ +- return 0; +-} +- +-static int +-clickfs_unmount(struct mount *mp, int mntflags, struct proc *p) ++clickfs_unmount(struct mount *mp, int mntflags, struct thread *td) + { + struct clickfs_mount *cmp = (struct clickfs_mount *)mp->mnt_data; + int error; +@@ -97,7 +88,7 @@ + if (mntflags & MNT_FORCE) + flags |= FORCECLOSE; + +- error = vflush(mp, 1, flags); // there is 1 extra vnode ref. ++ error = vflush(mp, 1, flags, td); // there is 1 extra vnode ref. + if (error) + return error; + +@@ -114,13 +105,13 @@ + + *vpp = cmp->click_root; + VREF(*vpp); +- vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curproc); ++ vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread); + + return 0; + } + + static int +-clickfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) ++clickfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) + { + memcpy(sbp, &mp->mnt_stat, sizeof(*sbp)); + return 0; +@@ -128,7 +119,7 @@ + + static int + clickfs_sync(struct mount *mp, int waitfor, struct ucred *cred, +- struct proc *p) ++ struct thread *td) + { + return 0; + } +@@ -145,19 +136,20 @@ + return 0; + } + +-struct vfsops clickfs_vfsops = { +- clickfs_mount, +- clickfs_start, +- clickfs_unmount, +- clickfs_root, +- vfs_stdquotactl, +- clickfs_statfs, +- clickfs_sync, +- vfs_stdvget, +- vfs_stdfhtovp, +- vfs_stdcheckexp, +- vfs_stdvptofh, +- clickfs_init, +- clickfs_uninit, +- vfs_stdextattrctl ++extern "C" struct vfsops clickfs_vfsops = { ++ clickfs_mount, ++ NULL, ++ clickfs_unmount, ++ clickfs_root, ++ NULL, ++ clickfs_statfs, ++ clickfs_sync, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ clickfs_init, ++ clickfs_uninit, ++ NULL, ++ NULL + }; Index: files/patch-bsdmodule__clickfs_vnops.cc =================================================================== RCS file: files/patch-bsdmodule__clickfs_vnops.cc diff -N files/patch-bsdmodule__clickfs_vnops.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-bsdmodule__clickfs_vnops.cc 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,153 @@ +--- bsdmodule/clickfs_vnops.cc.orig Thu Feb 1 11:06:43 2007 ++++ bsdmodule/clickfs_vnops.cc Fri Oct 13 04:50:02 2006 +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + CLICK_CXX_UNPROTECT + #include + +@@ -37,7 +38,7 @@ + + #define UIO_MX 32 + +-vop_t **clickfs_vnops; ++extern struct vop_vector clickfs_vnodeops; /* forward declaration */ + + static enum vtype clickfs_vtype[] = { + VDIR, /* CLICKFS_DIRENT_DIR */ +@@ -54,7 +55,7 @@ + struct clickfs_dirent *de; + int error; + +- error = getnewvnode(VT_NON, mp, clickfs_vnops, vpp); ++ error = getnewvnode("click", mp, &clickfs_vnodeops, vpp); + if (error) + return error; + de = clickfs_tree_root; +@@ -62,7 +63,7 @@ + vp = *vpp; + vp->v_data = de; + vp->v_type = clickfs_vtype[de->type]; +- vp->v_flag = VROOT; ++ vp->v_vflag = VV_ROOT; + return 0; + } + +@@ -74,7 +75,7 @@ + struct vnode *dvp = ap->a_dvp; + char *pname = cnp->cn_nameptr; + int plen = cnp->cn_namelen; +- struct proc *p = cnp->cn_proc; ++ struct thread *td = cnp->cn_thread; + struct clickfs_dirent *cde= VTOCDE(dvp); + int error = 0; + +@@ -84,7 +85,7 @@ + return ENOTDIR; + if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) + return EROFS; +- VOP_UNLOCK(dvp, 0, p); ++ VOP_UNLOCK(dvp, 0, td); + + if (plen == 1 && *pname == '.') { + *vpp = dvp; +@@ -105,19 +106,19 @@ + goto done; + } + +- error = getnewvnode(VT_NON, dvp->v_mount, clickfs_vnops, vpp); ++ error = getnewvnode("click", dvp->v_mount, &clickfs_vnodeops, vpp); + if (error) + goto done; + + (*vpp)->v_data = cde; + (*vpp)->v_type = clickfs_vtype[cde->type]; + if (cde == clickfs_tree_root) +- (*vpp)->v_flag = VROOT; +- vn_lock(*vpp, LK_SHARED | LK_RETRY, p); ++ (*vpp)->v_vflag = VV_ROOT; ++ vn_lock(*vpp, LK_SHARED | LK_RETRY, td); + return 0; + + done: +- vn_lock(dvp, LK_SHARED | LK_RETRY, p); ++ vn_lock(dvp, LK_SHARED | LK_RETRY, td); + return error; + } + +@@ -179,7 +180,7 @@ + cde->data.handle.r_offset = cde->data.handle.w_offset = 0; + vp->v_data = NULL; + vp->v_type = VNON; +- VOP_UNLOCK(vp, 0, ap->a_p); ++ VOP_UNLOCK(vp, 0, ap->a_td); + + return 0; + } +@@ -461,30 +462,38 @@ + return(clickfs_fsync_body(cde)); + } + +-int +-clickfs_default(struct vop_generic_args *ap) +-{ +- return(vop_defaultop(ap)); +-} +- +-static struct vnodeopv_entry_desc clickfs_root_vnop_entries[] = +-{ +- { &vop_default_desc, (vop_t *) clickfs_default }, +- { &vop_lookup_desc, (vop_t *) clickfs_lookup }, +- { &vop_getattr_desc, (vop_t *) clickfs_getattr }, +- { &vop_setattr_desc, (vop_t *) clickfs_setattr }, +- { &vop_reclaim_desc, (vop_t *) clickfs_reclaim }, +- { &vop_inactive_desc, (vop_t *) clickfs_inactive }, +- { &vop_access_desc, (vop_t *) clickfs_access }, +- { &vop_readdir_desc, (vop_t *) clickfs_readdir }, +- { &vop_open_desc, (vop_t *) clickfs_open }, +- { &vop_read_desc, (vop_t *) clickfs_read }, +- { &vop_write_desc, (vop_t *) clickfs_write }, +- { &vop_close_desc, (vop_t *) clickfs_close }, +- { &vop_fsync_desc, (vop_t *) clickfs_fsync }, +- { &vop_readlink_desc, (vop_t *) clickfs_readlink }, +- { (struct vnodeop_desc *) NULL, (int (*) (void *)) NULL } ++/* XXX: Blatant kludge as c++ does not like c99 initializers. */ ++static struct vop_vector clickfs_vnodeops = { ++ &default_vnodeops, ++ NULL, ++ NULL, ++ clickfs_lookup, ++ NULL, ++ NULL, ++ NULL, ++ clickfs_open, ++ clickfs_close, ++ clickfs_access, ++ clickfs_getattr, ++ clickfs_setattr, ++ clickfs_read, ++ clickfs_write, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ clickfs_fsync, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ clickfs_readdir, ++ clickfs_readlink, ++ clickfs_inactive, ++ clickfs_reclaim, ++ NULL, /* .. 5 at current revision */ + }; +- +-struct vnodeopv_desc clickfs_vnodeop_opv_desc = +-{ &clickfs_vnops, clickfs_root_vnop_entries }; Index: files/patch-bsdmodule__module.cc =================================================================== RCS file: files/patch-bsdmodule__module.cc diff -N files/patch-bsdmodule__module.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-bsdmodule__module.cc 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,71 @@ +--- bsdmodule/module.cc.orig Thu Feb 1 11:07:24 2007 ++++ bsdmodule/module.cc Fri Oct 13 03:08:46 2006 +@@ -315,68 +315,3 @@ + click_dmalloc_cleanup(); + } + } +- +-static int +-click_load(struct module *mod, int cmd, void *arg) +-{ +- int ret = ENOTSUP; +- +- /* Load and unload the VFS part first */ +- ret = vfs_modevent(mod, cmd, arg); +- if (ret) +- return ret; +- +- switch (cmd) { +- case MOD_LOAD: +- printf("Click module loading\n"); +- if (init_module()) { +- ret = EINVAL; +- break; +- } +- +- ret = 0; +- break; +- +- case MOD_UNLOAD: +- printf("Click module unloading\n"); +- cleanup_module(); +- ret = 0; +- break; +- +- case MOD_SHUTDOWN: +- /* +- * MOD_SHUTDOWN is usually called when the machine is +- * about to shut down and the module is loaded at the +- * moment. Perhaps we should call cleanup_module() at +- * this point, but since we're shutting down anyway, +- * it doesn't really matter.. +- */ +- printf("Click module shutdown\n"); +- ret = 0; +- break; +- +- default: +- printf("Click: unknown module command %d\n", cmd); +- ret = EINVAL; +- break; +- } +- +- return ret; +-} +- +-static struct vfsconf click_vfsconf = { +- &clickfs_vfsops, +- "click", +- -1, +- 0, +- VFCF_SYNTHETIC +-}; +- +-static moduledata_t mod_data = { +- "click", +- click_load, +- &click_vfsconf +-}; +- +-DECLARE_MODULE(click, mod_data, SI_SUB_VFS, SI_ORDER_MIDDLE); +-VNODEOP_SET(clickfs_vnodeop_opv_desc); Index: files/patch-bsdmodule__module_c.c =================================================================== RCS file: files/patch-bsdmodule__module_c.c diff -N files/patch-bsdmodule__module_c.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-bsdmodule__module_c.c 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,93 @@ +--- bsdmodule/module_c.c.orig Thu Feb 1 11:01:47 2007 ++++ bsdmodule/module_c.c Fri Oct 13 03:28:29 2006 +@@ -0,0 +1,90 @@ ++/* ++ * module_c.c -- FreeBSD kernel module glue ++ * ++ * Copyright (c) 2006 Bruce M. Simpson. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the "Software"), ++ * to deal in the Software without restriction, subject to the conditions ++ * listed in the Click LICENSE file. These conditions include: you must ++ * preserve this copyright notice, and you cannot mention the copyright ++ * holders in advertising related to the Software without their permission. ++ * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This ++ * notice is a summary of the Click LICENSE file; the license in that file is ++ * legally binding. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++extern int init_module(void); ++extern void cleanup_module(void); ++ ++extern struct vfsops clickfs_vfsops; ++ ++static int ++click_modevent(module_t mod, int type, void *data) ++{ ++ int ret; ++ ++ /* Load and unload the VFS part first */ ++ ret = vfs_modevent(mod, type, data); ++ if (ret != 0) { ++ return ret; ++ } ++ ++ switch (type) { ++ case MOD_LOAD: ++ printf("Click module loading\n"); ++ if (init_module()) { ++ ret = EINVAL; ++ break; ++ } ++ ret = 0; ++ break; ++ case MOD_UNLOAD: ++ printf("Click module unloading\n"); ++ cleanup_module(); ++ ret = 0; ++ break; ++ case MOD_SHUTDOWN: ++ printf("Click module shutdown\n"); ++ ret = 0; ++ break; ++ default: ++ printf("Click: unknown module command %d\n", type); ++ ret = EOPNOTSUPP; ++ break; ++ } ++ ++ return ret; ++} ++ ++/* ++ * We have to break the rules of VFS_SET() here somewhat. ++ */ ++static struct vfsconf click_vfsconf = { ++ VFS_VERSION, ++ "click", ++ &clickfs_vfsops, ++ -1, ++ 0, ++ VFCF_SYNTHETIC, ++ NULL, ++ NULL ++}; ++ ++static moduledata_t click_mod = { ++ "click", ++ click_modevent, ++ &click_vfsconf ++}; ++ ++DECLARE_MODULE(click, click_mod, SI_SUB_VFS, SI_ORDER_MIDDLE); Index: files/patch-bsdmodule__sched.cc =================================================================== RCS file: files/patch-bsdmodule__sched.cc diff -N files/patch-bsdmodule__sched.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-bsdmodule__sched.cc 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,36 @@ +--- bsdmodule/sched.cc.orig Thu Feb 1 11:07:30 2007 ++++ bsdmodule/sched.cc Thu Feb 1 10:53:11 2007 +@@ -317,11 +317,8 @@ + void + click_netisr(void) + { +- int s = splimp(); + RouterThread *rt = click_master->thread(0); +- + rt->driver(); +- splx(s); + } + + #endif //BSD_NETISRSCHED +@@ -344,10 +341,10 @@ + #endif + + #ifdef BSD_NETISRSCHED +- register_netisr(NETISR_CLICK, click_netisr); ++ netisr_register(NETISR_CLICK, click_netisr, NULL, 0); + schednetisr(NETISR_CLICK); + click_timer_h = timeout(click_timer, NULL, 1); +- click_dummyifnet.if_flags |= IFF_UP|IFF_RUNNING; ++ click_dummyifnet.if_flags |= IFF_UP|IFF_DRV_RUNNING; + #endif + + placeholder_router = new Router("", click_master); +@@ -403,7 +400,7 @@ + { + #ifdef BSD_NETISRSCHED + untimeout(click_timer, NULL, click_timer_h); +- unregister_netisr(NETISR_CLICK); ++ netisr_unregister(NETISR_CLICK); + ether_poll_deregister(&click_dummyifnet); + delete placeholder_router; + #else Index: files/patch-configure =================================================================== RCS file: files/patch-configure diff -N files/patch-configure --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-configure 1 Feb 2007 14:01:24 -0000 @@ -0,0 +1,54 @@ +--- configure.orig Fri May 19 21:50:14 2006 ++++ configure Thu Feb 1 11:15:48 2007 +@@ -4449,14 +4449,15 @@ + + =========================================" >&2;} + { (exit 1); exit 1; }; } +-elif test -r $freebsd_includedir/net/if_var.h -a -r $freebsd_srcdir/kern/vnode_if.pl; then ++elif test -r $freebsd_includedir/net/if_var.h -a -r $freebsd_srcdir/kern/vnode_if.src; then + ac_have_bsd_kernel=y ++ KERNEL_CXX="$KERNEL_CXX -fpermissive" + else + { { echo "$as_me:$LINENO: error: + ========================================= + + Can't find $freebsd_includedir/net/if_var.h and/or +-$freebsd_srcdir/kern/vnode_if.pl. Are you sure $freebsd_srcdir ++$freebsd_srcdir/kern/vnode_if.src. Are you sure $freebsd_srcdir + and $freebsd_includedir contain FreeBSD kernel source? + + =========================================" >&5 +@@ -4464,7 +4465,7 @@ + ========================================= + + Can't find $freebsd_includedir/net/if_var.h and/or +-$freebsd_srcdir/kern/vnode_if.pl. Are you sure $freebsd_srcdir ++$freebsd_srcdir/kern/vnode_if.src. Are you sure $freebsd_srcdir + and $freebsd_includedir contain FreeBSD kernel source? + + =========================================" >&2;} +@@ -12279,7 +12280,7 @@ + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + #include +-#if __FreeBSD_version < 440002 || __FreeBSD_version >= 500000 ++#if __FreeBSD_version < 500000 + #include + #endif + _ACEOF +@@ -12330,13 +12331,13 @@ + { echo "$as_me:$LINENO: WARNING: + ========================================= + +-Your version of FreeBSD is old. Click works with FreeBSD 4.5 and later. ++Your version of FreeBSD is old. Click works with FreeBSD 5.x and later. + + =========================================" >&5 + echo "$as_me: WARNING: + ========================================= + +-Your version of FreeBSD is old. Click works with FreeBSD 4.5 and later. ++Your version of FreeBSD is old. Click works with FreeBSD 5.x and later. + + =========================================" >&2;} + fi Index: files/patch-configure.in =================================================================== RCS file: files/patch-configure.in diff -N files/patch-configure.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-configure.in 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,42 @@ +--- configure.in.orig Fri May 19 21:48:10 2006 ++++ configure.in Thu Feb 1 11:15:37 2007 +@@ -208,14 +208,14 @@ + are relative. You must supply absolute paths starting with /. + + =========================================]) +-elif test -r $freebsd_includedir/net/if_var.h -a -r $freebsd_srcdir/kern/vnode_if.pl; then ++elif test -r $freebsd_includedir/net/if_var.h -a -r $freebsd_srcdir/kern/vnode_if.src; then + ac_have_bsd_kernel=y + else + AC_MSG_ERROR([ + ========================================= + + Can't find $freebsd_includedir/net/if_var.h and/or +-$freebsd_srcdir/kern/vnode_if.pl. Are you sure $freebsd_srcdir ++$freebsd_srcdir/kern/vnode_if.src. Are you sure $freebsd_srcdir + and $freebsd_includedir contain FreeBSD kernel source? + + =========================================]) +@@ -545,11 +545,12 @@ + dnl + + if test $ac_have_bsd_kernel = y; then ++ KERNEL_CXX="$KERNEL_CXX -fpermissive" + AC_CACHE_CHECK(FreeBSD version, ac_cv_freebsd_version, [ + save_flags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$freebsd_includedir" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include +-#if __FreeBSD_version < 440002 || __FreeBSD_version >= 500000 ++#if __FreeBSD_version < 500000 + #include + #endif]])], ac_cv_freebsd_version=yes, ac_cv_freebsd_version=no) + CPPFLAGS="$save_flags"]) +@@ -560,7 +561,7 @@ + AC_MSG_WARN([ + ========================================= + +-Your version of FreeBSD is old. Click works with FreeBSD 4.5 and later. ++Your version of FreeBSD is old. Click works with FreeBSD 5.x and later. + + =========================================]) + fi Index: files/patch-elements__bsdmodule__anydevice.cc =================================================================== RCS file: files/patch-elements__bsdmodule__anydevice.cc diff -N files/patch-elements__bsdmodule__anydevice.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__bsdmodule__anydevice.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,11 @@ +--- elements/bsdmodule/anydevice.cc.orig Thu Feb 1 12:48:26 2007 ++++ elements/bsdmodule/anydevice.cc Thu Feb 1 12:48:13 2007 +@@ -147,7 +147,7 @@ + return NULL; + + // look first by device names +- String dev_name = dev->if_name; ++ String dev_name = dev->if_xname; + for (AnyDevice *d = _unknown_map; d; d = d->next()) + if (d->devname() == dev_name) + return d; Index: files/patch-elements__bsdmodule__fastudpsrc.cc =================================================================== RCS file: files/patch-elements__bsdmodule__fastudpsrc.cc diff -N files/patch-elements__bsdmodule__fastudpsrc.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__bsdmodule__fastudpsrc.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,49 @@ +--- elements/bsdmodule/fastudpsrc.cc.orig Thu Feb 1 12:50:11 2007 ++++ elements/bsdmodule/fastudpsrc.cc Thu Feb 1 13:14:43 2007 +@@ -96,12 +96,12 @@ + // Create an mbuf with an mbuf cluster so copies are quick + // (we just add a reference to the cluster rather than doing + // a memory copy). +- MGETHDR(_m, M_WAIT, MT_DATA); ++ MGETHDR(_m, M_TRYWAIT, MT_DATA); + if (_m == NULL) { + click_chatter("unable to get mbuf for FastUDPSource"); + return -1; + } +- MCLGET(_m, M_WAIT); ++ MCLGET(_m, M_TRYWAIT); + if ((_m->m_flags & M_EXT) == 0) { + m_freem(_m); + click_chatter("unable to get mbuf cluster for FastUDPSource"); +@@ -165,20 +165,8 @@ + return 0; + } + +- if (mclrefcnt[mtocl(_m->m_ext.ext_buf)] >= SCHAR_MAX) { +- caddr_t mcl, mcl0; +- MCLALLOC(mcl, M_WAIT); +- if (!mcl) { +- click_chatter("failure to allocate new mbuf cluster\n"); +- return 0; +- } +- +- bcopy(_m->m_data, mcl, _m->m_len); +- mcl0 = _m->m_ext.ext_buf; +- _m->m_data = mcl; +- _m->m_ext.ext_buf = mcl; +- MCLFREE(mcl0); +- } ++ // FreeBSD's mbuf cluster refcounting was completely rewritten, ++ // so we don't need to check for the lame 127 references limitation. -bms + + bool need_packet = false; + if (_rate_limited) { +@@ -193,7 +181,7 @@ + if (!need_packet) + return 0; // nothing to pull + +- m = m_copypacket(_m, M_WAIT); ++ m = m_copypacket(_m, M_TRYWAIT); + if (!m) { + click_chatter("unable to m_copypacket\n"); + return 0; // bad luck. Index: files/patch-elements__bsdmodule__fromdevice.cc =================================================================== RCS file: files/patch-elements__bsdmodule__fromdevice.cc diff -N files/patch-elements__bsdmodule__fromdevice.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__bsdmodule__fromdevice.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,169 @@ +--- elements/bsdmodule/fromdevice.cc.orig Thu Feb 1 12:50:17 2007 ++++ elements/bsdmodule/fromdevice.cc Thu Feb 1 13:39:12 2007 +@@ -61,7 +61,7 @@ + + /* + * Process incoming packets using the ng_ether_input_p hook. +- * The if_poll_intren (normally unused) field from the struct ifnet is ++ * The if_spare2 (normally unused) field from the struct ifnet is + * used as a pointer to the fromdevice data structure. Call it "xp". + * + * If xp == NULL, no FromDevice element is registered on this +@@ -78,7 +78,7 @@ + void + click_ether_input(struct ifnet *ifp, struct mbuf **mp, struct ether_header *eh) + { +- if (ifp->if_poll_intren == NULL) // not for click. ++ if (ifp->if_spare2 == NULL) // not for click. + return ; + + struct mbuf *m = *mp; +@@ -89,8 +89,9 @@ + + *mp = NULL; // tell ether_input no further processing needed. + +- FromDevice *me = (FromDevice *)(ifp->if_poll_intren); ++ FromDevice *me = (FromDevice *)(ifp->if_spare2); + ++#if 0 /* XXX: needs rewriting for polling(4) rewrite. -bms */ + /* + * If sysctl kern.polling.enable == 2 we should take care of polling + * this NIC from inside a Click thread, so steal the handler from BSD. +@@ -106,26 +107,27 @@ + me->_poll_status_tick = ticks; + prp->handler = NULL; + prp->ifp = NULL; +- printf("Click FromDevice(%s%d) taking control over NIC driver polling\n", ifp->if_name, ifp->if_unit); ++ printf("Click FromDevice(%s) taking control over NIC driver polling\n", ifp->if_xname); + me->_polling = -1; // wakeup task thread only once more + break; + } + if (!me->_polling) { +- printf("Strange, couldn't find polling handler for %s%d\n", +- ifp->if_name, ifp->if_unit); ++ printf("Strange, couldn't find polling handler for %s\n", ++ ifp->if_xname); + me->_polling = -2; // Do not bother trying to register again + } + } ++#endif + + // put the ethernet header back into the mbuf. + M_PREPEND(m, sizeof(*eh), M_WAIT); + bcopy(eh, mtod(m, struct ether_header *), sizeof(*eh)); + +- if (IF_QFULL(me->_inq)) { +- IF_DROP(me->_inq); ++ if (_IF_QFULL(me->_inq)) { ++ _IF_DROP(me->_inq); + m_freem(m); + } else +- IF_ENQUEUE(me->_inq, m); ++ _IF_ENQUEUE(me->_inq, m); + if (me->_polling != 1) + me->intr_reschedule(); + if (me->_polling == -1) +@@ -137,9 +139,9 @@ + + /* + * Process outgoing packets using the ng_ether_output_p hook. +- * If if_poll_xmit == NULL, no FromHost element is registered on this ++ * If if_spare3 == NULL, no FromHost element is registered on this + * interface, so return 0 to pass the packet back to FreeBSD. +- * Otherwise, if_poll_xmit points to the element, which in turn contains ++ * Otherwise, if_spare3 points to the element, which in turn contains + * a queue. Append the packet there, clear *mp to grab the pkt from FreeBSD, + * and possibly wakeup the element. + * +@@ -150,19 +152,19 @@ + click_ether_output(struct ifnet *ifp, struct mbuf **mp) + { + int s = splimp(); +- if (ifp->if_poll_xmit == NULL) { // not for click... ++ if (ifp->if_spare3 == NULL) { // not for click... + splx(s); + return 0; + } + struct mbuf *m = *mp; + *mp = NULL; // tell ether_output no further processing needed + +- FromHost *me = (FromHost *)(ifp->if_poll_xmit); +- if (IF_QFULL(me->_inq)) { +- IF_DROP(me->_inq); ++ FromHost *me = (FromHost *)(ifp->if_spare3); ++ if (_IF_QFULL(me->_inq)) { ++ _IF_DROP(me->_inq); + m_freem(m); + } else +- IF_ENQUEUE(me->_inq, m); ++ _IF_ENQUEUE(me->_inq, m); + me->intr_reschedule(); + splx(s); + return 0; +@@ -280,7 +282,7 @@ + malloc(sizeof (struct ifqueue), M_DEVBUF, M_NOWAIT|M_ZERO); + assert(_inq); + _inq->ifq_maxlen = QSIZE; +- (FromDevice *)(device()->if_poll_intren) = this; ++ (FromDevice *)(device()->if_spare2) = this; + } else { + if (_readers == 0) + printf("Warning, _readers mismatch (should not be 0)\n"); +@@ -324,7 +326,7 @@ + if (_readers == 0) { // flush queue + q = _inq ; + _inq = NULL ; +- device()->if_poll_intren = NULL ; ++ device()->if_spare2 = NULL ; + } + if (_polling == 1) { // return polling handler to the kernel + struct pollrec *prp = pr; +@@ -334,7 +336,7 @@ + break; + prp->handler = _poll_handler; + prp->ifp = _dev; +- if (*poll_handlers == 0 && (_dev->if_flags & IFF_RUNNING)) ++ if (*poll_handlers == 0 && (_dev->if_drv_flags & IFF_DRV_RUNNING)) + *poll_handlers = 1; + } + splx(s); +@@ -355,12 +357,14 @@ + ifpromisc(device(), 0); + } + ++#if 0 /* XXX: method signature has disappeared. -bms */ + void + FromDevice::take_state(Element *e, ErrorHandler *errh) + { + FromDevice *fd = (FromDevice *)e->cast("FromDevice"); + if (!fd) return; + } ++#endif + + bool + FromDevice::run_task() +@@ -368,6 +372,7 @@ + int npq = 0; + // click_chatter("FromDevice::run_task()."); + ++#if 0 /* XXX: See polling(4). -bms */ + if (_dev && _polling == 1) { + if (_dev->if_ipending & IFF_POLLING) { + enum poll_cmd cmd; +@@ -387,13 +392,15 @@ + break; + prp->handler = _poll_handler; + prp->ifp = _dev; +- if (*poll_handlers == 0 && (_dev->if_flags & IFF_RUNNING)) ++ if (*poll_handlers == 0 && ++ (_dev->if_drv_flags & IFF_DRV_RUNNING)) + *poll_handlers = 1; + } else + _poll_handler(_dev, cmd, _burst); + } else + _polling = 0; // No more polling + } ++#endif + + #ifdef FROMDEVICE_TSTAMP + if (_tstamp) { Index: files/patch-elements__bsdmodule__fromhost.cc =================================================================== RCS file: files/patch-elements__bsdmodule__fromhost.cc diff -N files/patch-elements__bsdmodule__fromhost.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__bsdmodule__fromhost.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,41 @@ +--- elements/bsdmodule/fromhost.cc.orig Thu Feb 1 12:58:40 2007 ++++ elements/bsdmodule/fromhost.cc Thu Feb 1 13:36:09 2007 +@@ -57,15 +57,17 @@ + int + FromHost::initialize(ErrorHandler *errh) + { ++#if 1 /* XXX: Needs rewritten to use new polling and netisr handlers. -bms */ ++ return -1; ++#else + // create queue + int s = splimp(); +- if (device()->if_poll_xmit != NULL) { ++ if (device()->if_spare3 != NULL) { + splx(s); +- click_chatter("FromHost: %s%d already in use", +- device()->if_name, device()->if_unit); ++ click_chatter("FromHost: %s already in use", device()->if_xname); + return -1; + } +- (FromHost *)(device()->if_poll_xmit) = this; ++ (FromHost *)(device()->if_spare3) = this; + _inq = (struct ifqueue *) + malloc(sizeof (struct ifqueue), M_DEVBUF, M_NOWAIT|M_ZERO); + assert(_inq); +@@ -73,6 +75,7 @@ + ScheduleInfo::initialize_task(this, &_task, true, errh); + splx(s); + return 0; ++#endif + } + + void +@@ -85,7 +88,7 @@ + int s = splimp(); + struct ifqueue *q = _inq ; + _inq = NULL; +- device()->if_poll_xmit = NULL; ++ device()->if_spare3 = NULL; + splx(s); + + int i, max = q->ifq_maxlen ; Index: files/patch-elements__bsdmodule__todevice.cc =================================================================== RCS file: files/patch-elements__bsdmodule__todevice.cc diff -N files/patch-elements__bsdmodule__todevice.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__bsdmodule__todevice.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,19 @@ +--- elements/bsdmodule/todevice.cc.orig Thu Feb 1 13:26:58 2007 ++++ elements/bsdmodule/todevice.cc Thu Feb 1 13:29:21 2007 +@@ -28,6 +28,7 @@ + #include + #include + ++#include + + /* for watching when devices go offline */ + static AnyDeviceMap to_device_map; +@@ -132,7 +133,7 @@ + int sent = 0; + // click_chatter("ToDevice::run_task()."); + +- while (sent < _burst && (busy = IF_QFULL(&device()->if_snd)) == 0) { ++ while (sent < _burst && (busy = _IF_QFULL(&device()->if_snd)) == 0) { + + Packet *p = input(0).pull(); + if (!p) Index: files/patch-elements__bsdmodule__tohost.cc =================================================================== RCS file: files/patch-elements__bsdmodule__tohost.cc diff -N files/patch-elements__bsdmodule__tohost.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__bsdmodule__tohost.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,15 @@ +--- elements/bsdmodule/tohost.cc.orig Thu Feb 1 12:59:08 2007 ++++ elements/bsdmodule/tohost.cc Thu Feb 1 13:33:26 2007 +@@ -115,7 +115,12 @@ + + m->m_pkthdr.rcvif = NULL; // tell click-ether-input to ignore this + m_adj(m, ETHER_HDR_LEN); ++#if 1 ++ /* XXX: ether_input() is now declared static. -bms */ ++ (*ifp->if_input)(ifp, m); ++#else + ether_input(ifp, eh, m); ++#endif + } + + String Index: files/patch-elements__grid__filterbyhops.cc =================================================================== RCS file: files/patch-elements__grid__filterbyhops.cc diff -N files/patch-elements__grid__filterbyhops.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-elements__grid__filterbyhops.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,11 @@ +--- elements/grid/filterbyhops.cc.orig Thu Feb 1 13:39:53 2007 ++++ elements/grid/filterbyhops.cc Thu Feb 1 13:40:36 2007 +@@ -24,7 +24,7 @@ + #include + #include + #include "grid.hh" +-#include ++//#include + CLICK_DECLS + + FilterByGridHops::FilterByGridHops() Index: files/patch-include__click__task.hh =================================================================== RCS file: files/patch-include__click__task.hh diff -N files/patch-include__click__task.hh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-include__click__task.hh 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,75 @@ +--- include/click/task.hh.orig Wed Dec 21 03:26:21 2005 ++++ include/click/task.hh Thu Feb 1 11:54:18 2007 +@@ -9,19 +9,13 @@ + #endif + CLICK_DECLS + +-#ifdef CLICK_BSDMODULE +-# include +-# include /* MARKO XXX */ +-#endif +- +-#if CLICK_BSDMODULE && !BSD_NETISRSCHED +-# define SPLCHECK \ +- int s = splimp(); \ +- if (s == 0) \ +- panic("not spl'ed: %d\n", s); \ +- splx(s) ++#if CLICK_BSDMODULE ++extern "C" { ++ #include ++ #include ++} + #else +-# define SPLCHECK ++#define GIANT_REQUIRED + #endif + + #define PASS_GT(a, b) ((int)(a - b) > 0) +@@ -319,8 +313,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- // assert(!intr_nesting_level); +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + if (scheduled()) { + #ifdef HAVE_TASK_HEAP +@@ -401,8 +394,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- // assert(!intr_nesting_level); it happens all the time from fromdevice! +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + + if (!scheduled()) { +@@ -443,7 +435,7 @@ + inline void + Task::fast_schedule() + { +- SPLCHECK; ++ GIANT_REQUIRED; + assert(_tickets >= 1); + #if HAVE_TASK_HEAP + _pass = (_thread->active() ? _thread->_task_heap[0]->_pass : 0); +@@ -465,7 +457,7 @@ + #endif + #if CLICK_BSDMODULE + // assert(!intr_nesting_level); +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + if (!scheduled()) { + _prev = _thread->_prev; +@@ -494,7 +486,7 @@ + inline void + Task::reschedule() + { +- SPLCHECK; ++ GIANT_REQUIRED; + assert(_thread); + if (!scheduled()) + true_reschedule(); Index: files/patch-lib__routerthread.cc =================================================================== RCS file: files/patch-lib__routerthread.cc diff -N files/patch-lib__routerthread.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-lib__routerthread.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,11 @@ +--- lib/routerthread.cc.orig Thu Feb 1 11:33:31 2007 ++++ lib/routerthread.cc Fri Oct 13 03:52:57 2006 +@@ -422,7 +422,7 @@ + if (_greedy) + /* do nothing */; + else if (active()) { // just schedule others for a moment +- yield(curproc, NULL); ++ yield(curthread, NULL); + } else { + _sleep_ident = &_sleep_ident; // arbitrary address, != NULL + tsleep(&_sleep_ident, PPAUSE, "pause", 1); Index: files/patch-lib__task.cc =================================================================== RCS file: files/patch-lib__task.cc diff -N files/patch-lib__task.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-lib__task.cc 1 Feb 2007 14:01:25 -0000 @@ -0,0 +1,62 @@ +--- lib/task.cc.orig Thu Feb 1 11:33:38 2007 ++++ lib/task.cc Fri Oct 13 03:51:26 2006 +@@ -220,8 +220,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- assert(!intr_nesting_level); +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + if (_thread) { + lock_tasks(); +@@ -242,8 +241,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- // assert(!intr_nesting_level); it happens all the time from fromdevice! +- SPLCHECK; ++ // GIANT_REQUIRED; + #endif + + if (!scheduled()) { +@@ -271,9 +269,6 @@ + if (in_interrupt()) + goto skip_lock; + #endif +-#if CLICK_BSDMODULE +- SPLCHECK; +-#endif + if (attempt_lock_tasks()) { + if (_router->_running >= Router::RUNNING_BACKGROUND) { + if (!scheduled()) { +@@ -308,8 +303,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- assert(!intr_nesting_level); +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + // unschedule() and move to a quiescent thread, so that subsequent + // reschedule()s won't have any effect +@@ -340,8 +334,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- assert(!intr_nesting_level); +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + assert(_thread); + lock_tasks(); +@@ -369,8 +362,7 @@ + assert(!in_interrupt()); + #endif + #if CLICK_BSDMODULE +- assert(!intr_nesting_level); +- SPLCHECK; ++ GIANT_REQUIRED; + #endif + if (thread_id < RouterThread::THREAD_QUIESCENT) + thread_id = RouterThread::THREAD_QUIESCENT;