summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-28 10:16:45 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-28 10:16:45 +0000
commitdd2b8403a85186728d2280050afeae817692a102 (patch)
tree2be6ccc8bb7e213382b01dd964b542fc91a7a1e9 /sys/net
parentcba989db5ef2c262d2eeb2ee6f56d8c75d717d38 (diff)
Change the way protocol multicast addresses are linked to an interface.
Instead of linking multicast records to the first configured address of the corresponding protocol, making this address and its position in the global list special, add them to a new list directly linked to the interface descriptor. This new multicast address list is similar to the address list, all its elements contain a protocol agnostic part. This design allows us to be able to join a multicast group without necessarily having a configured address. That means IPv6 multicast kludges are no longer needed. Another benefit is to be able to add and remove an IP address from an interface without worrying about multicast records. That means that the global IPv4 list is no longer needed since the first configured address of an interface is no longer special. This new list might also be extended in the future to contain the link-layer addresses used to configure hardware filters. Tested by sthen@ and weerd@, ok mikeb@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c5
-rw-r--r--sys/net/if_var.h13
2 files changed, 15 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 8926e751a3d..4000f40dd35 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.278 2013/11/27 08:34:40 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.279 2013/11/28 10:16:44 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -437,8 +437,9 @@ if_attach(struct ifnet *ifp)
void
if_attach_common(struct ifnet *ifp)
{
-
TAILQ_INIT(&ifp->if_addrlist);
+ TAILQ_INIT(&ifp->if_maddrlist);
+
ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks),
M_TEMP, M_WAITOK);
TAILQ_INIT(ifp->if_addrhooks);
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 5d7f8c406b3..884ded3347f 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.1 2013/11/21 17:32:12 mikeb Exp $ */
+/* $OpenBSD: if_var.h,v 1.2 2013/11/28 10:16:44 mpi Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -123,6 +123,7 @@ struct ifnet { /* and the entries */
TAILQ_ENTRY(ifnet) if_list; /* all struct ifnets are chained */
TAILQ_ENTRY(ifnet) if_txlist; /* list of ifnets ready to tx */
TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */
+ TAILQ_HEAD(, ifmaddr) if_maddrlist; /* list of multicast records */
TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
struct hook_desc_head *if_addrhooks; /* address change callbacks */
struct hook_desc_head *if_linkstatehooks; /* link change callbacks */
@@ -305,6 +306,16 @@ struct ifaddr_item {
};
/*
+ * Interface multicast address.
+ */
+struct ifmaddr {
+ struct sockaddr *ifma_addr; /* Protocol address */
+ struct ifnet *ifma_ifp; /* Back pointer to ifnet */
+ unsigned int ifma_refcnt; /* Count of references */
+ TAILQ_ENTRY(ifmaddr) ifma_list; /* Per-interface list */
+};
+
+/*
* interface groups
*/