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.
Created attachment 82841 [details, diff] udhcp-cidrroutes.patch Patch to udhcp.
Created attachment 82842 [details, diff] baselayout-rfc3442-udhcp.patch Patch to baselayout.
the patch to the udhcp code needs to go upstream ... we dont do custom patches in Gentoo for that package
what do other dhcp clients use as a shortname for option 121 ?
(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.
>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.
Get upstream to support this.