summaryrefslogtreecommitdiff
path: root/sys/net/if.c
AgeCommit message (Collapse)Author
2017-01-23i botched the copyout to ifr->ifr_data in SIOCGIFDATA.David Gwynne
this lets pflogd run again. rename if_data() to if_getdata() while here to make grepping for things less noisy. reported by jsg@ worked through with deraadt@
2017-01-23merge the ifnet and ifqueue stats together when userland wants them.David Gwynne
a new if_data() function takes a pointer to ifnet and merges its if_data and ifq statistics. it takes the ifq mutex around the reads of the ifq stats so they get a consistent copy. the ifnet and ifq stats are merged because some parts of the stack still update the ifnet counters. ok visa@ (on an earlier diff) mpi@ claudio@
2017-01-22move counting if_opackets next to counting if_obytes in if_enqueue.David Gwynne
this means packets are consistently counted in one place, unlike the many and various ways that drivers thought they should do it. ok mpi@ deraadt@
2017-01-12Unlink PF state keys before passing mbufs to drivers.Martin Pieuchot
Network drivers shouldn't have to deal with PF data structures. This change prevent m_free(9) called from an interrupt handler at IPL_NET to mess with pf(4) internals. Prevent an splassert reported by Mark Patruck. ok mikeb@, bluhm@
2017-01-04dont assume setting IFF_UP will succeed.David Gwynne
run a drivers ioctl handler and check if it worked before calling if_up or if_down to report the change. propagate that error up to userland so ifconfig can report what happened. ok mpi@
2017-01-04shuffle the last change slightly.David Gwynne
only check ml_empty the second time if bpf was run and may have filtered the list. only call task_add if mq_enlist worked.
2017-01-04make if_input return early if the mbuf list is empty.David Gwynne
this saves doing wakeups of the softnet thread. ok deraadt@
2017-01-03Do not trash the original SPL level.Martin Pieuchot
Pointed out by and ok jsg@, ok mikeb@
2016-12-29Change NET_LOCK()/NET_UNLOCK() to be simple wrappers aroundMartin Pieuchot
splsoftnet()/splx() until the known issues are fixed. In other words, stop using a rwlock since it creates a deadlock when chrome is used. Issue reported by Dimitris Papastamos and kettenis@ ok visa@
2016-12-21Generate an IFINFO message when changing the MTU of an interface.Jeremie Courreges-Anglas
Helps route(4) listeners to refresh their knowledge of the MTU of interfaces. Prompted by a diff for ospfd(8) by Remi Locherer, ok claudio@
2016-12-20Grab the netlock during interface attach and detach.Mike Belopuhov
With help from and OK mpi.
2016-12-19Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsMartin Pieuchot
of the network stack that are not yet ready to be executed in parallel or where new sleeping points are not possible. This first pass replace all the entry points leading to ip_output(). This is done to not introduce new sleeping points when trying to acquire ART's write lock, needed when a new L2 entry is created via the RT_RESOLVE. Inputs from and ok bluhm@, ok dlg@
2016-12-12Remove most of the splsoftnet() recursions related to cloned interfaces.Martin Pieuchot
inputs and ok bluhm@
2016-12-02Clean up leftovers from r1.442.Vincent Gross
Local var 'up' is never set in ifioctl(). OK mpi@
2016-11-28Remove simple recursive splsoftnet() calls inside ifioctl().Martin Pieuchot
2016-11-21Enforce that pr_usrreq functions are called at IPL_SOFTNET.Martin Pieuchot
This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. ok bluhm@, claudio@
2016-11-14Automatically set ::1 on all default lo(4) interfaces.Martin Pieuchot
Prodded by claudio@
2016-11-14It should be possible to create the default loopback interface.Martin Pieuchot
Make rdomain's default loopback test pass again.
2016-11-14Automatically create a default lo(4) interface per rdomain.Martin Pieuchot
In order to stop abusing lo0 for all rdomains, a new loopback interface will be created every time a rdomain is created. The unit number will be the same as the rdomain, i.e. lo1 will be attached to rdomain 1. If this loopback interface is already in use it wont be possible to create the corresponding rdomain. In order to know which lo(4) interface is attached to a rdomain, its index is stored in the rtable/rdomain map. This is a long overdue since the introduction of rtable/rdomain. It also fixes a recent regression due to resetting the rdomain of an incoming packet reported by semarie@, Andreas Bartelt and Nils Frohberg. ok claudio@
2016-11-08No longer need radix.hMartin Pieuchot
2016-11-08RIP ifa_ifwithnet()Martin Pieuchot
ok vgross@
2016-10-19Remove the if_input task from the correct taskq.YASUOKA Masahiko
ok bluhm henning
2016-10-16m_resethdr() clears information attached to a mbuf that has beenAlexander Bluhm
accumulated during processing, especially pf(4) data is removed. When a packet is reinserted to local input processing, we have to start from scratch with a clean mbuf header. Also the packet has to be in the routing doamin of the interface where it is inserted. Incoming packet with stale inp pointer seen by patrick@ on lo(4); OK sashan@ mpi@
2016-10-09This needs radix.h because it uses rn_refines().Claudio Jeker
OK guenther@
2016-10-07Use detach hook to notify switch(4) about interface removals instead ofRafael Zalamena
adding code to if.c. ok mpi@
2016-10-03Use detach hook to notify bridge of interface removal instead of addingRafael Zalamena
code to if.c. ok mpi@
2016-09-28Fix a kernel panic that happened when destroying interfaces attached toRafael Zalamena
the switch(4) without prior removal. ok reyk@, goda@
2016-09-22Raise spl level to IPL_SOFTNET before calling rt_ifmsg().Martin Pieuchot
From dhill@, found the hardway by semarie@
2016-09-20Create and destroy cloneable interfaces under splsoftnetMike Belopuhov
With and ok mpi, tested by David Hill and tb@, thanks!
2016-09-13Split if_linkstate_task() in two to avoid SPL recursion when theMartin Pieuchot
linkstate is changed from if_up() & if_down(). ok claudio@
2016-09-08Replace two if/do/while dances by while loops.Martin Pieuchot
Requested by and ok dlg@
2016-09-07Rename rtable_mpath_next() into rtable_iterate() and make it do a properMartin Pieuchot
reference count. rtable_iterate() frees the passed ``rt'' and returns the next one on the multipath list or NULL if there's none. ok dlg@
2016-09-05Rename if_linkstate() to if_linkstate_task() and make sure that all callersClaudio Jeker
pass the ifindex to that function and not the ifp. This fixes the missing link state change messages on if_up and if_down. This is a fix for Rev 1.444 which introduced this problem. OK florian@
2016-09-04Prevent a race between a thread detaching an interface and the watchdogMartin Pieuchot
or linkstate task sleeping. Pass an index to the task and use if_get(9) if the ifp is still alive. Found the hardway by awolk@. ok claudio@, bluhm@, mikeb@
2016-09-04When auto-creating an interface when opening a /dev/{tun,tap,switch}Reyk Floeter
device, inherit the rdomain from the calling process. This adds an rdomain argument to if_clone_create(). OK mpi@ henning@
2016-09-04Move code to change the rdomain of an interface from the ioctl switch caseReyk Floeter
to a new function if_setrdomain(). OK mpi@ henning@
2016-09-04Purge routes attached to an address when this address is removed.Martin Pieuchot
This is done to stop using stale ifa attached to routes, which is the easiest way to make rtisvalid(9) MP-safe. sthen@ and henning@ like it, ok claudio@
2016-09-03Remove routes added by the kernel before userland ones.Martin Pieuchot
This is a correctness change that will allow us to check that nothing happend with kernel added routes.
2016-09-03Use per-ifp tasks to process incoming packets.Martin Pieuchot
Reduce the number of if_get/if_put from one per packet to one per ring since we now know that all the packets are coming from the same interface. Improve forwarding performances by 10Kpps in Hrvoje Popovski's test setup. ok bluhm@, henning@, dlg@
2016-09-01Import switch(4), an in-kernel OpenFlow switch which can work alone.Kazuya Goda
switch(4) currently supports OpenFlow 1.3.5. Currently, it's disabled by the kernel config. With help from yasuoka@ reyk@ jsg@. ok deraadt@ yasuoka@ reyk@ henning@
2016-08-11take TASKQ_CANTSLEEP way from the softnet taskq.David Gwynne
the big reason for this is to let us use rw locks in the network stack, which is how at least two major efforts outside the tree have approached making pf mpsafe. this was discussed at length at n2k16. there was general agreement that this is necessary for us to move smp work forward in the stack.
2016-07-13Move ARP processing back to the KERNEL_LOCK()ed task until the raceMartin Pieuchot
triggered by updating a cached, but removed from the table, entry is properly fixed. Diff from dlg@, prodding deraadt@
2016-07-12Directly drop packets filtered by bpf(4) instead of going through theMartin Pieuchot
input handlers. ok dlg@
2016-06-10Add the "llprio" field to struct ifnet, and the corresponding keywordVincent Gross
to ifconfig. "llprio" allows one to set the priority of packets that do not go through pf(4), as the case is for arp(4) or bpf(4). ok sthen@ mikeb@
2016-05-18rework the srp api so it takes an srp_ref struct that the caller provides.David Gwynne
the srp_ref struct is used to track the location of the callers hazard pointer so later calls to srp_follow and srp_enter already know what to clear. this in turn means most of the caveats around using srps go away. specifically, you can now: - switch cpus while holding an srp ref - ie, you can sleep while holding an srp ref - you can take and release srp refs in any order the original intent was to simplify use of the api when dealing with complicated data structures. the caller now no longer has to track the location of the srp a value was fetched from, the srp_ref effectively does that for you. srp lists have been refactored to use srp_refs instead of srpl_iter structs. this is in preparation of using srps inside the ART code. ART is a complicated data structure, and lookups require overlapping holds of srp references. ok mpi@ jmatthew@
2016-05-10make bpf_mtap callers set the M_FILDROP flag if they care about it.David Gwynne
ok mpi@
2016-05-08Do not export the IFXF_MPSAFE flag to userland, it is a kernel-onlyMartin Pieuchot
hint. ok kettenis@, deraadt@
2016-05-03Stop using a soft-interrupt context to process incoming network packets.Martin Pieuchot
Use a new task that runs holding the KERNEL_LOCK to execute mp-unsafe code. Our current goal is to progressively move input functions to the unlocked task. This gives a small performance boost confirmed by Hrvoje Popovski's IPv4 forwarding measurement: before: after: send receive send receive 400kpps 400kpps 400kpps 400kpps 500kpps 500kpps 500kpps 500kpps 600kpps 600kpps 600kpps 600kpps 650kpps 650kpps 650kpps 640kpps 700kpps 700kpps 700kpps 700kpps 720kpps 640kpps 720kpps 710kpps 800kpps 640kpps 800kpps 650kpps 1.4Mpps 570kpps 1.4Mpps 590kpps 14Mpps 570kpps 14Mpps 590kpps ok kettenis@, bluhm@, dlg@
2016-03-16if ticks diverge from ifq_congestion too far the diff will go negativeDavid Gwynne
detect this and bump ifq_congestion forward rather than claim the system is congested for a long period of time. ok mpi@ henning@ jmatthew@
2016-03-07Sync no-argument function declaration and definition by adding (void).Christian Weisgerber
ok mpi@ millert@