Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 127149 - rfc3442 support in udhcp client
Summary: rfc3442 support in udhcp client
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 127151
  Show dependency tree
 
Reported: 2006-03-21 23:05 UTC by Alexander Zubkov
Modified: 2007-07-12 13:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
udhcp-cidrroutes.patch (udhcp-cidrroutes.patch,350 bytes, patch)
2006-03-21 23:06 UTC, Alexander Zubkov
Details | Diff
baselayout-rfc3442-udhcp.patch (baselayout-rfc3442-udhcp.patch,2.14 KB, patch)
2006-03-21 23:06 UTC, Alexander Zubkov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zubkov 2006-03-21 23:05:15 UTC
Here is patches to add support of rfc3442 (classles static routes
in dhcp) to udhcp and its network script.

1) Patch to udhcp-0.9.9_pre20041216-r1:
----------------------------------------
--- udhcp.orig/options.c	2006-03-21 15:11:56.576831750 +0300
+++ udhcp/options.c	2006-03-21 15:15:00.004295250 +0300
@@ -43,6 +43,7 @@
 	{"message",	OPTION_STRING,				0x38},
 	{"tftp",	OPTION_STRING,				0x42},
 	{"bootfile",	OPTION_STRING,				0x43},
+	{"cidrroute",	OPTION_U8 | OPTION_LIST | OPTION_REQ,	0x79},
 	{"",		0x00,				0x00}
 };
 
----------------------------------------
It adds dhcp option 121 to clients requests and names it "cidrroute" - I've not  think out better in 9 letters.

2) Patch to baselayout-1.11.14-r6:
----------------------------------------
--- rc-scripts-1.6.14.orig/lib/rcscripts/net.modules.d/helpers.d/udhcpc-iproute2	2006-03-21 17:40:09.528606500 +0300
+++ rc-scripts-1.6.14/lib/rcscripts/net.modules.d/helpers.d/udhcpc-iproute2	2006-03-21 18:31:19.872491000 +0300
@@ -62,14 +62,50 @@
 eval dhcp=\" \$\{dhcp_${interface}\} \"
 if [[ ${dhcp} != *' nogateway '* ]]; then
     # Configure our default route
-    x=$(ip route show | awk '{ if ($1 == "default") {print $3} }')
     for r in ${router}; do
 	# We can only have one default route!
-	if [[ -z ${x} ]]; then
-	    ip route add default via ${r} dev ${interface} 2>/dev/null && break
-	elif [[ ${x} != ${r} ]]; then
-	    ip route change default via ${r} dev ${interface} 2>/dev/null && break
-	fi
+        ip route replace default via ${r} dev ${interface} 2>/dev/null && break
+    done
+fi
+
+# Configure static routes
+if [[ "${cidrroute}" ]]; then
+    cidrroute="${cidrroute} "
+    # Work while cidrroute not empty
+    while true; do
+        # First go number of bits in mask
+        bits=${cidrroute%% *}
+        [[ -z ${bits} ]] && break
+        cidrroute=${cidrroute#* }
+        pref=""
+        if [[ ${bits} == 0 ]]; then
+            # We got 0/0 here
+            pref="default"
+        else
+            # Calc how many bytes we need to get from cidrroute
+            # And get them in prefix
+            bytes=$(( (${bits} - 1) / 8 + 1 ))
+            while [[ ${bytes} > 0 ]]; do
+                byte=${cidrroute%% *}
+                cidrroute=${cidrroute#* }
+                pref="${pref}.${byte}"
+                bytes=$(( ${bytes} - 1 ))
+            done
+            pref=${pref#.}
+            pref="${pref}/${bits}"
+        fi
+        # We have subnet prefix now and need to get gateway same way
+        bytes=4
+        gw=""
+        while [[ ${bytes} > 0 ]]; do
+            byte=${cidrroute%% *}
+            cidrroute=${cidrroute#* }
+            gw="${gw}.${byte}"
+            bytes=$(( ${bytes} - 1 ))
+        done
+        gw=${gw#.}
+        # And add the next route finally
+        ip route replace ${pref} via ${gw} dev ${interface} 2>/dev/null
     done
 fi
 
----------------------------------------
This adds support of cidrroutes variable to udhcpc-iproute2 helper. So udhcpc with iproute2 can now set up routes if server return option 121.
Comment 1 Alexander Zubkov 2006-03-21 23:06:26 UTC
Created attachment 82841 [details, diff]
udhcp-cidrroutes.patch

Patch to udhcp.
Comment 2 Alexander Zubkov 2006-03-21 23:06:57 UTC
Created attachment 82842 [details, diff]
baselayout-rfc3442-udhcp.patch

Patch to baselayout.
Comment 3 SpanKY gentoo-dev 2006-03-22 06:31:47 UTC
the patch to the udhcp code needs to go upstream ... we dont do custom patches in Gentoo for that package
Comment 4 SpanKY gentoo-dev 2006-03-22 19:33:23 UTC
what do other dhcp clients use as a shortname for option 121 ?
Comment 5 Roy Marples (RETIRED) gentoo-dev 2006-03-23 02:12:14 UTC
(In reply to comment #4)
> what do other dhcp clients use as a shortname for option 121 ?
> 

No clients offically support option 121 yet that I know of.
Comment 6 Alexander Zubkov 2006-03-23 02:24:25 UTC
>the patch to the udhcp code needs to go upstream ...
> we dont do custom patches in Gentoo for that package

As I mention from their README - changing options.c file is a sort of configuring. It is like parameters you pass to configure, for example.

> what do other dhcp clients use as a shortname for option 121 ?
> 

I have not seen any names to this option in other dhcp clients - dhclient, dhcpcd, pump. If you have better names - it'll be good, but the problem is in 9 letters only.
Comment 7 Roy Marples (RETIRED) gentoo-dev 2007-07-12 13:55:38 UTC
Get upstream to support this.