9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@labs.coraid.com>
To: 9fans@9fans.net
Subject: [9fans] dhcpd change
Date: Thu, 26 Aug 2010 17:02:01 -0400	[thread overview]
Message-ID: <430e483145536a76fa566b2341f51719@coraid.com> (raw)

currently, i'm working on migrating a couple of large
ip networks from one ip block to another.  rather than
a big flag day, we are overlaying the new network on
the same segment as the old network, thus, ether0
has both ip networks assigned.  this confuses dhcpd
because it thinks addresses belonging to the second
network are martians, and doesn't respond.  here's
one possible solution:

/n/sources/plan9//sys/src/cmd/ip/dhcpd/ndb.c:190,195 - ndb.c:170,214
  	return 0;
  }

+ static int
+ mksamenet(Info *ii, Info *gii)
+ {
+ 	uchar x[IPaddrlen];
+ 	Ipifc *ifc;
+ 	Iplifc *lifc, *nexus;
+
+ 	maskip(ii->ipaddr, gii->ipmask, x);
+ 	if(ipcmp(x, gii->ipnet) == 0)
+ 		return 0;
+
+ 	/* find ii's interface */
+ 	for(ifc = ipifcs;; ifc = ifc->next){
+ 		if(ifc == nil)
+ 			return -1;
+ 		for(lifc = ifc->lifc; lifc != nil; lifc = lifc->next){
+ 			maskip(ii->ipaddr, lifc->mask, x);
+ 			if(ipcmp(x, lifc->net) == 0)
+ 				goto found;
+ 		}
+ 	}
+ found:
+ 	nexus = lifc;
+ 	/* check to see that gii appears on same interface */
+ 	for(lifc = ifc->lifc;; lifc = lifc->next){
+ 		if(lifc == nil)
+ 			return -1;
+ 		if(ipcmp(lifc->net, gii->ipnet) == 0)
+ 			break;
+ 	}
+
+ 	/* fixup incorrect gii information */
+ 	if(lookupip(nexus->ip, gii, 1) < 0)
+ 		return -1;
+ 	syslog(1, blog, "nexus %I %I is %s:%I\n",
+ 		ii->ipaddr, gii->ipaddr, ifc->dev, nexus->net);
+ 	return 0;
+ }
+
  static uchar zeroes[6];

  /*
/n/sources/plan9//sys/src/cmd/ip/dhcpd/ndb.c:263,269 - ndb.c:284,290
  			parseip(ciaddr, nt->val);
  			if(lookupip(ciaddr, iip, 0) < 0)
  				continue;
- 			if(samenet(riip->ipaddr, iip)){
+ 			if(mksamenet(iip, riip) == 0){
  				ndbfree(t);
  				return 0;
  			}

- erik



                 reply	other threads:[~2010-08-26 21:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=430e483145536a76fa566b2341f51719@coraid.com \
    --to=quanstro@labs.coraid.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).