In usr/src/cmd/cmd-inet/lib/nwamd/routing_events.c:routing_events_v4(), 
no IF_STATE events are generated for any routing socket messages if the 
address is 0.0.0.0.

However, in ncu_ip.c:nwamd_ncu_handle_if_state_event(), there is code 
for a bug workaround that checks the address on the interface if the 
routing socket message was a DELADDR/FREEADDR for 0.0.0.0.  More 
specifically, the following code:

    1092         if (family == AF_INET && !if_state->nwe_addr_added) {
    1093             /*
    1094              * Check for failure due to CR 6745448: if we get a
    1095              * report that an address has been deleted, then check
    1096              * for interface up, datalink down, and actual address
    1097              * non-zero.  If that combination is seen, then this is
    1098              * a DHCP cached lease, and we need to remove it from
    1099              * the system, or it'll louse up the kernel routes
    1100              * (which aren't smart enough to avoid dead
    1101              * interfaces).
    1102              */
    1103             /*LINTED*/
    1104             if (((struct sockaddr_in *)addr)->sin_addr.s_addr
    1105                 == INADDR_ANY) {
    1106                 socklen_t slen;
    1107                 struct sockaddr_in s;
    1108                 int pfxlen;
    1109
    1110                 if ((flags & IFF_UP) &&
    1111                     !(flags & IFF_RUNNING) &&
    1112                     icfg_get_addr(ifh, (struct sockaddr *)&s,
    1113 &slen, &pfxlen, B_FALSE) == ICFG_SUCCESS &&
    1114                     s.sin_addr.s_addr != INADDR_ANY) {
    1115                     nlog(LOG_DEBUG, "bug workaround: "
    1116                         "clear out addr %s on %s",
    1117                         inet_ntoa(s.sin_addr), ifname);
    1118                     s.sin_addr.s_addr = INADDR_ANY;
    1119                     (void) icfg_set_addr(ifh,
    1120                         (const struct sockaddr *)&s, slen);
    1121                 }
    1122                 icfg_close(ifh);
    1123                 goto exit;
    1124             }
    1125         }

This code is never executed in nwamd_ncu_handle_if_state_event().  Is 
this code necessary?  If so, it should be moved to routing_events_v4().

Another reason I ask this question is that libipadm does not allow the 
setting of 0.0.0.0 address.  The only this that can be done here (after 
consulting with libipadm expert Girish) is ipadm_delete_addr() followed 
by ipadm_create_addr() with a DHCP address.  If the DHCP server is not 
available (which appears to be the case here since the comments suggest 
that the datalink is down), then the 0.0.0.0 address will be set on the 
interface while trying to get the DHCP address and lease.  Is this the 
intended behavior for such a scenario?

Thanks,
Anurag

Reply via email to