summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mrouted/config.c
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>1999-01-20 07:55:57 +0000
committerfenner <fenner@FreeBSD.org>1999-01-20 07:55:57 +0000
commitcdafdeb1c3a36e7c0b59fd4f6f0b90b3b1cc27f8 (patch)
treeccf540c94528b6508bed4892f971ca6ff14c68a7 /usr.sbin/mrouted/config.c
parent1de14dda19dab2b943562326a3d97281534dc709 (diff)
downloadFreeBSD-src-cdafdeb1c3a36e7c0b59fd4f6f0b90b3b1cc27f8.zip
FreeBSD-src-cdafdeb1c3a36e7c0b59fd4f6f0b90b3b1cc27f8.tar.gz
Merge conflicts from 3.9-beta3+IOS12. The conflicts were huge; cvs's
merge algorithm failed on several files, and the translation of the mrouted man page to mdoc didn't help...
Diffstat (limited to 'usr.sbin/mrouted/config.c')
-rw-r--r--usr.sbin/mrouted/config.c66
1 files changed, 46 insertions, 20 deletions
diff --git a/usr.sbin/mrouted/config.c b/usr.sbin/mrouted/config.c
index 61f43eb..544199e 100644
--- a/usr.sbin/mrouted/config.c
+++ b/usr.sbin/mrouted/config.c
@@ -5,15 +5,21 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
+ *
+ *
+ * config.c,v 3.8.4.10 1998/01/06 01:57:41 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: config.c,v 1.11 1998/01/16 07:17:41 charnier Exp $";
+ "$Id: config.c,v 1.12 1998/06/09 05:01:29 imp Exp $";
#endif /* not lint */
#include "defs.h"
+
+struct ifconf ifc;
+
/*
* Query the kernel to find network interfaces that are multicast-capable
* and install them in the uvifs array.
@@ -21,28 +27,48 @@ static const char rcsid[] =
void
config_vifs_from_kernel()
{
- struct ifreq ifbuf[32];
struct ifreq *ifrp, *ifend;
- struct ifconf ifc;
register struct uvif *v;
register vifi_t vifi;
int n;
u_int32 addr, mask, subnet;
short flags;
+ int num_ifreq = 32;
+
+ ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
+ ifc.ifc_buf = malloc(ifc.ifc_len);
+ while (ifc.ifc_buf) {
+ if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
+ log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
+
+ /*
+ * If the buffer was large enough to hold all the addresses
+ * then break out, otherwise increase the buffer size and
+ * try again.
+ *
+ * The only way to know that we definitely had enough space
+ * is to know that there was enough space for at least one
+ * more struct ifreq. ???
+ */
+ if ((num_ifreq * sizeof(struct ifreq)) >=
+ ifc.ifc_len + sizeof(struct ifreq))
+ break;
- ifc.ifc_buf = (char *)ifbuf;
- ifc.ifc_len = sizeof(ifbuf);
- if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
- log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
+ num_ifreq *= 2;
+ ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
+ ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
+ }
+ if (ifc.ifc_buf == NULL)
+ log(LOG_ERR, 0, "config_vifs_from_kernel: ran out of memory");
- ifrp = (struct ifreq *)ifbuf;
- ifend = (struct ifreq *)((char *)ifbuf + ifc.ifc_len);
+ ifrp = (struct ifreq *)ifc.ifc_buf;
+ ifend = (struct ifreq *)(ifc.ifc_buf + ifc.ifc_len);
/*
* Loop through all of the interfaces.
*/
for (; ifrp < ifend; ifrp = (struct ifreq *)((char *)ifrp + n)) {
struct ifreq ifr;
-#if BSD >= 199006
+#ifdef HAVE_SA_LEN
n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
if (n < sizeof(*ifrp))
n = sizeof(*ifrp);
@@ -97,6 +123,12 @@ config_vifs_from_kernel()
* one already installed in the uvifs array.
*/
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
+ if (strcmp(v->uv_name, ifr.ifr_name) == 0) {
+ log(LOG_DEBUG, 0, "skipping %s (%s on subnet %s) (alias for vif#%u?)",
+ v->uv_name, inet_fmt(addr, s1),
+ inet_fmts(subnet, mask, s2), vifi);
+ break;
+ }
if ((addr & v->uv_subnetmask) == v->uv_subnet ||
(v->uv_subnet & mask) == subnet) {
log(LOG_WARNING, 0, "ignoring %s, same subnet as %s",
@@ -114,22 +146,16 @@ config_vifs_from_kernel()
continue;
}
v = &uvifs[numvifs];
- v->uv_flags = 0;
- v->uv_metric = DEFAULT_METRIC;
- v->uv_admetric = 0;
- v->uv_rate_limit = DEFAULT_PHY_RATE_LIMIT;
- v->uv_threshold = DEFAULT_THRESHOLD;
+ zero_vif(v, 0);
v->uv_lcl_addr = addr;
- v->uv_rmt_addr = 0;
v->uv_subnet = subnet;
v->uv_subnetmask = mask;
v->uv_subnetbcast = subnet | ~mask;
strncpy(v->uv_name, ifr.ifr_name, IFNAMSIZ);
v->uv_name[IFNAMSIZ-1] = '\0';
- v->uv_groups = NULL;
- v->uv_neighbors = NULL;
- v->uv_acl = NULL;
- v->uv_addrs = NULL;
+
+ if (flags & IFF_POINTOPOINT)
+ v->uv_flags |= VIFF_REXMIT_PRUNES;
log(LOG_INFO,0,"installing %s (%s on subnet %s) as vif #%u - rate=%d",
v->uv_name, inet_fmt(addr, s1), inet_fmts(subnet, mask, s2),
OpenPOWER on IntegriCloud