git: if_tap: Restore SIOCGIFFLAGS, SIOC[GS]IFADDR ioctls for tapioctl()

2018-07-19 Thread Aaron LI
commit d4daa541d3579963aea225dace938f1bf58edd27 Author: Aaron LI Date: Thu Jul 19 15:04:35 2018 +0800 if_tap: Restore SIOCGIFFLAGS, SIOC[GS]IFADDR ioctls for tapioctl() These ioctls allow basic control of the network interface via the device file (/dev/tapX). For example, ou

git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Aaron LI
commit 6f90efb8f9ac6785b04c25efb90c432dcdb142af Author: Aaron LI Date: Sat Jul 7 23:16:19 2018 +0800 if_tun: Use pointer to ifnet in tun_softc struct Use a pointer to the ifnet struct in the tun_softc struct, instead of embedding a full ifnet struct in it. (similar to FreeBS

git: if_tun: Update tun.4 man page to match the code

2018-07-19 Thread Aaron LI
commit b24712baecd0d6a60456e438a12293241e320636 Author: Aaron LI Date: Tue Jul 17 19:04:12 2018 +0800 if_tun: Update tun.4 man page to match the code Mainly follow FreeBSD's tun.4, refer to NetBSD's tun.4, and with my own minor adjustments. Summary of changes: share/man/man

git: if_tun: Some small tweaks and cleanups

2018-07-19 Thread Aaron LI
commit 0db5ecf136b9c767d1b577710a0fb9bcc838b2f3 Author: Aaron LI Date: Sat Jul 7 20:49:04 2018 +0800 if_tun: Some small tweaks and cleanups * Consistently use the TUN define instead of "tun". * Use variable "sc" instead of "tp" to refer to "struct tun_softc". *

git: if_tun: Support module load and unload

2018-07-19 Thread Aaron LI
commit e9ff9cbbb2f67488b832b985884330539eb236cf Author: Aaron LI Date: Sun Jul 8 09:43:12 2018 +0800 if_tun: Support module load and unload Track the created tun devices in a list, and record the number of opened tun devices. Destroy all tun devices when unloading the module

git: if_tun: Implement interface clone support

2018-07-19 Thread Aaron LI
commit 925b0cbfbfed7123f1222f6b5650b7747937015d Author: Aaron LI Date: Sun Jul 8 21:07:20 2018 +0800 if_tun: Implement interface clone support Now 'ifconfig tunX create' and 'ifconfig tunX destroy' work. The tun device will be automatically destroyed when being closed,

git: if_tun: Allow IP packets of length TUNMRU with TUNSIFHEAD set

2018-07-19 Thread Aaron LI
commit b6f0123246e7c8525d2f5a5ff4f3014d1f5f8b66 Author: Aaron LI Date: Tue Jul 17 19:57:55 2018 +0800 if_tun: Allow IP packets of length TUNMRU with TUNSIFHEAD set Obtained-from: FreeBSD (revision 300205) Summary of changes: sys/net/tun/if_tun.c | 7 +-- 1 file changed, 5 i

git: if_tun: Disallow change network device type

2018-07-19 Thread Aaron LI
commit 017d03c14dd62ab3eaf8e62b04a5d0abca2a559c Author: Aaron LI Date: Mon Jul 9 12:45:24 2018 +0800 if_tun: Disallow change network device type Disallow ioctl(2) to change the network device type of tun(4). Otherwise, page faults and panics can happen when access uninitializ

git: if_tun: Add "cdev_t tun_dev" to tun_softc struct

2018-07-19 Thread Aaron LI
commit 860e305a4e6cc899b09479646ac55eaca5b142f1 Author: Aaron LI Date: Sat Jul 7 23:21:18 2018 +0800 if_tun: Add "cdev_t tun_dev" to tun_softc struct Similar to if_tap, save the tun device in the tun_softc struct. Summary of changes: sys/net/tun/if_tun.c| 3 +++ sys/net/tun

git: if_tun: Better name interface-related functions

2018-07-19 Thread Aaron LI
commit a6b12a18cc0bfcc7350772075da413d16a3f67f1 Author: Aaron LI Date: Sun Jul 8 19:55:36 2018 +0800 if_tun: Better name interface-related functions Rename interface-related functions to be 'tunifxxx', and reorder a bit to better group them. Tweak the styles and impr

git: if_tun: Add sysctl net.link.tun.{refcnt,debug}

2018-07-19 Thread Aaron LI
commit 98e874e52520ad50c29307adf4754a2465666477 Author: Aaron LI Date: Sun Jul 8 10:17:20 2018 +0800 if_tun: Add sysctl net.link.tun.{refcnt,debug} Add read-only sysctl net.link.tun.refcnt to show the number of opened devices. Add sysctl net.link.tun.debug to be a al

git: if_tun: Raise maximum MTU to be 65535 bytes

2018-07-19 Thread Aaron LI
commit 9abf54c01ae57593a8ff5ee7381adca8a67005cb Author: Aaron LI Date: Thu Jul 5 14:08:43 2018 +0800 if_tun: Raise maximum MTU to be 65535 bytes This is used, for example, by packetdrill to test with MTU's up to the maximum value. Taken-from: FreeBSD (revision 300603

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Sepherosa Ziehau
How about move the following logic into if_alloc(): + ifp = sc->tun_ifp = if_alloc(IFT_PPP); + if (ifp == NULL) + /* XXX: should return an error */ + panic("%s%d: failed to if_alloc() interface", TUN, minor(dev)); i.e. if_alloc never fails. On Thu, Jul 19

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Sepherosa Ziehau
Just panic if_com_alloc[type]() fails. On Thu, Jul 19, 2018 at 5:20 PM, Aaron LI wrote: > On Thu, 19 Jul 2018 17:00:44 +0800 > Sepherosa Ziehau wrote: > >> How about move the following logic into if_alloc(): >> >> + ifp = sc->tun_ifp = if_alloc(IFT_PPP); >> + if (ifp == NULL) >> +

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Aaron LI
On Fri, 20 Jul 2018 09:09:07 +0800 Sepherosa Ziehau wrote: > Just panic if_com_alloc[type]() fails. > Ok, I'll do it. I'll also look at the drivers to make them use if_alloc() and if_free() when appropriate. Cheers, -- Aaron pgppTtS70LbYz.pgp Description: OpenPGP digital signature

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Sepherosa Ziehau
Most of the physical drivers are ethernet ones, so they need arpcom; please do w/ care. I am not quite sure why we want to use if_alloc() in the first place? We don't have the synchronization issue if_alloc() tries to address in FreeBSD. On Fri, Jul 20, 2018 at 9:29 AM, Aaron LI wrote: > On Fri

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Aaron LI
On Fri, 20 Jul 2018 09:40:21 +0800 Sepherosa Ziehau wrote: > Most of the physical drivers are ethernet ones, so they need arpcom; > please do w/ care. Sure, I have to understand the drivers more before really touching them. > I am not quite sure why we want to use if_alloc() in the first place?

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Sepherosa Ziehau
On Fri, Jul 20, 2018 at 10:19 AM, Aaron LI wrote: > On Fri, 20 Jul 2018 09:40:21 +0800 > Sepherosa Ziehau wrote: > >> Most of the physical drivers are ethernet ones, so they need arpcom; >> please do w/ care. > > Sure, I have to understand the drivers more before really touching them. > >> I am n

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Aaron LI
On Fri, 20 Jul 2018 10:43:16 +0800 Sepherosa Ziehau wrote: > On Fri, Jul 20, 2018 at 10:19 AM, Aaron LI wrote: > > On Fri, 20 Jul 2018 09:40:21 +0800 > > Sepherosa Ziehau wrote: > > > >> I am not quite sure why we want to use if_alloc() in the first place? > > > > Since our if_alloc() is ve

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Sepherosa Ziehau
Well, I don't think if_alloc makes sense for Dfly. But if you have already changed some code, then let it be. On Fri, Jul 20, 2018 at 11:19 AM, Aaron LI wrote: > On Fri, 20 Jul 2018 10:43:16 +0800 > Sepherosa Ziehau wrote: > >> On Fri, Jul 20, 2018 at 10:19 AM, Aaron LI wrote: >> > On Fri, 20

Re: git: if_tun: Use pointer to ifnet in tun_softc struct

2018-07-19 Thread Aaron LI
OK, thanks. I'll keep looking at the net code, and can improve it later. On Fri, 20 Jul 2018 12:07:00 +0800 Sepherosa Ziehau wrote: > Well, I don't think if_alloc makes sense for Dfly. But if you have > already changed some code, then let it be. > > On Fri, Jul 20, 2018 at 11:19 AM, Aaron LI