X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/7f274f01d8cb136e85705e6282cbcf86e0ea6811..70d9a675bf5441cc854a843ead702d08928c37f3:/sys/net/if_var.h diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 0dbc03334a..6cd1c82116 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -88,7 +88,7 @@ struct ifaddr_container; struct ifaddr; struct lwkt_port; struct lwkt_msg; -struct netmsg; +union netmsg; struct pktinfo; struct ifpoll_info; @@ -108,7 +108,7 @@ struct ifpoll_info; TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */ TAILQ_HEAD(ifaddrhead, ifaddr_container); /* instantiation is preserved in the list */ TAILQ_HEAD(ifprefixhead, ifprefix); -LIST_HEAD(ifmultihead, ifmultiaddr); +TAILQ_HEAD(ifmultihead, ifmultiaddr); /* * Structure defining a queue for a network interface. @@ -195,6 +195,7 @@ enum ifnet_serialize { */ struct ifnet { void *if_softc; /* pointer to driver state */ + void *if_l2com; /* pointer to protocol bits */ TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ char if_xname[IFNAMSIZ]; /* external name (name + unit) */ const char *if_dname; /* driver name */ @@ -232,6 +233,8 @@ struct ifnet { (struct ifnet *, struct sockaddr **, struct sockaddr *); int (*if_start_cpuid) /* cpuid to run if_start */ (struct ifnet *); + TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ + /* protected by if_addr_mtx */ #ifdef DEVICE_POLLING void (*if_poll) /* IFF_POLLING support */ (struct ifnet *, enum poll_cmd, int); @@ -270,7 +273,14 @@ struct ifnet { struct lwkt_serialize *if_serializer; /* serializer or MP lock */ struct lwkt_serialize if_default_serializer; /* if not supplied */ int if_cpuid; - struct netmsg *if_start_nmsg; /* percpu messages to schedule if_start */ + struct netmsg_base *if_start_nmsg; /* percpu msgs to sched if_start */ + void *if_pf_kif; /* pf interface abstraction */ + union { + void *carp_s; /* carp structure (used by !carp ifs) */ + struct ifnet *carp_d; /* ptr to carpdev (used by carp ifs) */ + } if_carp_ptr; + #define if_carp if_carp_ptr.carp_s + #define if_carpdev if_carp_ptr.carp_d }; typedef void if_init_f_t (void *); @@ -353,6 +363,10 @@ typedef void if_init_f_t (void *); #ifdef _KERNEL +/* interface link layer address change event */ +typedef void (*iflladdr_event_handler_t)(void *, struct ifnet *); +EVENTHANDLER_DECLARE(iflladdr_event, iflladdr_event_handler_t); + #ifdef INVARIANTS #define ASSERT_IFNET_SERIALIZED_ALL(ifp) \ (ifp)->if_serialize_assert((ifp), IFNET_SERIALIZE_ALL, TRUE) @@ -567,7 +581,7 @@ struct ifprefix { * address, not a count of pointers to this structure. */ struct ifmultiaddr { - LIST_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ + TAILQ_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ struct sockaddr *ifma_addr; /* address this membership is for */ struct sockaddr *ifma_lladdr; /* link-layer translation, if any */ struct ifnet *ifma_ifp; /* back-pointer to interface */ @@ -594,6 +608,39 @@ EVENTHANDLER_DECLARE(ifnet_attach_event, ifnet_attach_event_handler_t); typedef void (*ifnet_detach_event_handler_t)(void *, struct ifnet *); EVENTHANDLER_DECLARE(ifnet_detach_event, ifnet_detach_event_handler_t); +/* + * interface groups + */ +struct ifg_group { + char ifg_group[IFNAMSIZ]; + u_int ifg_refcnt; + void *ifg_pf_kif; + int ifg_carp_demoted; + TAILQ_HEAD(, ifg_member) ifg_members; + TAILQ_ENTRY(ifg_group) ifg_next; +}; + +struct ifg_member { + TAILQ_ENTRY(ifg_member) ifgm_next; + struct ifnet *ifgm_ifp; +}; + +struct ifg_list { + struct ifg_group *ifgl_group; + TAILQ_ENTRY(ifg_list) ifgl_next; +}; + +/* group attach event */ +typedef void (*group_attach_event_handler_t)(void *, struct ifg_group *); +EVENTHANDLER_DECLARE(group_attach_event, group_attach_event_handler_t); +/* group detach event */ +typedef void (*group_detach_event_handler_t)(void *, struct ifg_group *); +EVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t); +/* group change event */ +typedef void (*group_change_event_handler_t)(void *, const char *); +EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t); + + #ifdef INVARIANTS #define ASSERT_IFAC_VALID(ifac) do { \ KKASSERT((ifac)->ifa_magic == IFA_CONTAINER_MAGIC); \ @@ -624,6 +671,7 @@ IFAREF(struct ifaddr *_ifa) MALLOC_DECLARE(M_IFADDR); MALLOC_DECLARE(M_IFMADDR); +MALLOC_DECLARE(M_IFNET); void ifac_free(struct ifaddr_container *, int); @@ -649,6 +697,7 @@ struct lwkt_port *ifnet_portfn(int); int ifnet_domsg(struct lwkt_msg *, int); void ifnet_sendmsg(struct lwkt_msg *, int); void ifnet_forwardmsg(struct lwkt_msg *, int); +struct ifnet *ifnet_byindex(unsigned short); static __inline int ifa_domsg(struct lwkt_msg *_lmsg, int _cpu) @@ -668,6 +717,10 @@ ifa_forwardmsg(struct lwkt_msg *_lmsg, int _nextcpu) ifnet_forwardmsg(_lmsg, _nextcpu); } +#define REINPUT_KEEPRCVIF 0x0001 /* ether_reinput_oncpu() */ +#define REINPUT_RUNBPF 0x0002 /* ether_reinput_oncpu() */ + + extern struct ifnethead ifnet; extern struct ifnet **ifindex2ifnet; extern int ifqmaxlen; @@ -679,7 +732,6 @@ void ether_ifattach_bpf(struct ifnet *, uint8_t *, u_int, u_int, struct lwkt_serialize *); void ether_ifdetach(struct ifnet *); void ether_demux_oncpu(struct ifnet *, struct mbuf *); -void ether_input_oncpu(struct ifnet *, struct mbuf *); void ether_reinput_oncpu(struct ifnet *, struct mbuf *, int); void ether_input_chain(struct ifnet *, struct mbuf *, const struct pktinfo *, struct mbuf_chain *); @@ -687,6 +739,7 @@ void ether_input_chain_init(struct mbuf_chain *); void ether_input_dispatch(struct mbuf_chain *); int ether_output_frame(struct ifnet *, struct mbuf *); int ether_ioctl(struct ifnet *, int, caddr_t); +struct ifnet *ether_bridge_interface(struct ifnet *ifp); uint32_t ether_crc32_le(const uint8_t *, size_t); uint32_t ether_crc32_be(const uint8_t *, size_t); @@ -694,6 +747,7 @@ int if_addmulti(struct ifnet *, struct sockaddr *, struct ifmultiaddr **); int if_allmulti(struct ifnet *, int); void if_attach(struct ifnet *, struct lwkt_serialize *); int if_delmulti(struct ifnet *, struct sockaddr *); +void if_delallmulti(struct ifnet *ifp); void if_purgeaddrs_nolink(struct ifnet *); void if_detach(struct ifnet *); void if_down(struct ifnet *); @@ -701,6 +755,8 @@ void if_link_state_change(struct ifnet *); void if_initname(struct ifnet *, const char *, int); int if_getanyethermac(uint16_t *, int); int if_printf(struct ifnet *, const char *, ...) __printflike(2, 3); +struct ifnet *if_alloc(uint8_t); +void if_free(struct ifnet *); void if_route(struct ifnet *, int flag, int fam); int if_setlladdr(struct ifnet *, const u_char *, int); void if_unroute(struct ifnet *, int flag, int fam); @@ -711,17 +767,30 @@ int ifpromisc(struct ifnet *, int); struct ifnet *ifunit(const char *); struct ifnet *if_withname(struct sockaddr *); +struct ifg_group *if_creategroup(const char *); +int if_addgroup(struct ifnet *, const char *); +int if_delgroup(struct ifnet *, const char *); +int if_getgroup(caddr_t, struct ifnet *); +int if_getgroupmembers(caddr_t); + struct ifaddr *ifa_ifwithaddr(struct sockaddr *); struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); struct ifaddr *ifa_ifwithnet(struct sockaddr *); struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *); +typedef void *if_com_alloc_t(u_char type, struct ifnet *ifp); +typedef void if_com_free_t(void *com, u_char type); +void if_register_com_alloc(u_char, if_com_alloc_t *a, if_com_free_t *); +void if_deregister_com_alloc(u_char); + void *ifa_create(int, int); void ifa_destroy(struct ifaddr *); void ifa_iflink(struct ifaddr *, struct ifnet *, int); void ifa_ifunlink(struct ifaddr *, struct ifnet *); +struct ifaddr *ifaddr_byindex(unsigned short); + struct ifmultiaddr *ifmaof_ifpforaddr(struct sockaddr *, struct ifnet *); int if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen); void if_devstart(struct ifnet *ifp);