system-stats: Don't bother calling kill() after read_pidfile().
[sliver-openvswitch.git] / lib / dhcp-client.c
index 961994a..a0999bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@
 #include "timeval.h"
 #include "vlog.h"
 
-VLOG_DEFINE_THIS_MODULE(dhcp_client)
+VLOG_DEFINE_THIS_MODULE(dhcp_client);
 
 #define DHCLIENT_STATES                         \
     DHCLIENT_STATE(INIT, 1 << 0)                \
@@ -851,7 +851,7 @@ state_transition(struct dhclient *cli, enum dhclient_state state)
     bool am_bound;
 
     if (cli->state != state) {
-        VLOG_DBG("%s: entering %s", cli_name, state_name(state)); 
+        VLOG_DBG("%s: entering %s", cli_name, state_name(state));
         cli->state = state;
     }
     cli->state_entered = time_now();
@@ -894,7 +894,6 @@ send_reliably(struct dhclient *cli,
         do_send_msg(cli, &msg);
         cli->delay = MIN(cli->max_timeout, MAX(4, cli->delay * 2));
         cli->retransmit += fuzz(cli->delay, 1);
-        timeout(cli, cli->retransmit);
         dhcp_msg_uninit(&msg);
      }
 }
@@ -934,15 +933,13 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg)
     const char *cli_name = dhclient_get_name(cli);
     uint8_t cli_mac[ETH_ADDR_LEN];
     struct ofpbuf b;
-    int mtu;
 
-    netdev_get_mtu(cli->netdev, &mtu);
-    ofpbuf_init(&b, mtu + VLAN_ETH_HEADER_LEN);
+    ofpbuf_init(&b, ETH_TOTAL_MAX + VLAN_ETH_HEADER_LEN);
     netdev_get_etheraddr(cli->netdev, cli_mac);
     for (; cli->received < 50; cli->received++) {
         const struct ip_header *ip;
         const struct dhcp_header *dhcp;
-        flow_t flow;
+        struct flow flow;
         int error;
 
         ofpbuf_clear(&b);
@@ -953,7 +950,7 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg)
 
         flow_extract(&b, 0, 0, &flow);
         if (flow.dl_type != htons(ETH_TYPE_IP)
-            || flow.nw_proto != IP_TYPE_UDP
+            || flow.nw_proto != IPPROTO_UDP
             || flow.tp_dst != htons(DHCP_CLIENT_PORT)
             || !(eth_addr_is_broadcast(flow.dl_dst)
                  || eth_addr_equals(flow.dl_dst, cli_mac))) {
@@ -980,7 +977,7 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg)
         if (!error) {
             if (VLOG_IS_DBG_ENABLED()) {
                 VLOG_DBG_RL(&rl, "%s: received %s", cli_name,
-                            dhcp_msg_to_string(msg, false, &cli->s)); 
+                            dhcp_msg_to_string(msg, false, &cli->s));
             } else {
                 VLOG_INFO_RL(&rl, "%s: received %s",
                              cli_name, dhcp_type_name(msg->type));
@@ -1025,7 +1022,7 @@ do_send_msg(struct dhclient *cli, const struct dhcp_msg *msg)
     nh.ip_id = 0;
     nh.ip_frag_off = htons(IP_DONT_FRAGMENT);
     nh.ip_ttl = 64;
-    nh.ip_proto = IP_TYPE_UDP;
+    nh.ip_proto = IPPROTO_UDP;
     nh.ip_csum = 0;
     nh.ip_src = dhclient_get_ip(cli);
     /* XXX need to use UDP socket for nonzero server IPs so that we can get
@@ -1046,7 +1043,7 @@ do_send_msg(struct dhclient *cli, const struct dhcp_msg *msg)
     th.udp_csum = 0;
     udp_csum = csum_add32(0, nh.ip_src);
     udp_csum = csum_add32(udp_csum, nh.ip_dst);
-    udp_csum = csum_add16(udp_csum, IP_TYPE_UDP << 8);
+    udp_csum = csum_add16(udp_csum, IPPROTO_UDP << 8);
     udp_csum = csum_add16(udp_csum, th.udp_len);
     udp_csum = csum_continue(udp_csum, &th, sizeof th);
     th.udp_csum = csum_finish(csum_continue(udp_csum, b.data, b.size));
@@ -1062,7 +1059,7 @@ do_send_msg(struct dhclient *cli, const struct dhcp_msg *msg)
     if (b.size <= ETH_TOTAL_MAX) {
         if (VLOG_IS_DBG_ENABLED()) {
             VLOG_DBG("%s: sending %s",
-                     cli_name, dhcp_msg_to_string(msg, false, &cli->s)); 
+                     cli_name, dhcp_msg_to_string(msg, false, &cli->s));
         } else {
             VLOG_INFO("%s: sending %s", cli_name, dhcp_type_name(msg->type));
         }