dhcp: disable extraneous vlib_log spew
[vpp.git] / src / plugins / dhcp / client.c
index f38e3fd..8dc57cb 100644 (file)
@@ -25,10 +25,10 @@ dhcp_client_main_t dhcp_client_main;
 static vlib_node_registration_t dhcp_client_process_node;
 
 #define DHCP_DBG(...)                           \
-    vlib_log_debug (dhcp_logger, __VA_ARGS__);
+    vlib_log_debug (dhcp_logger, __VA_ARGS__)
 
 #define DHCP_INFO(...)                          \
-    vlib_log_notice (dhcp_logger, __VA_ARGS__);
+    vlib_log_notice (dhcp_logger, __VA_ARGS__)
 
 #define foreach_dhcp_sent_packet_stat           \
 _(DISCOVER, "DHCP discover packets sent")       \
@@ -516,6 +516,7 @@ send_dhcp_pkt (dhcp_client_main_t * dcm, dhcp_client_t * c,
   ASSERT (b->current_data == 0);
 
   vnet_buffer (b)->sw_if_index[VLIB_RX] = c->sw_if_index;
+  b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
 
   if (ADJ_INDEX_INVALID == c->ai_ucast)
     is_broadcast = 1;
@@ -658,8 +659,10 @@ send_dhcp_pkt (dhcp_client_main_t * dcm, dhcp_client_t * c,
   if (vec_len (c->client_identifier))
     {
       o->option = 61;
-      o->length = vec_len (c->client_identifier);
-      clib_memcpy (o->data, c->client_identifier,
+      o->length = vec_len (c->client_identifier) + 1;
+      /* Set type to zero, apparently some dhcp servers care */
+      o->data[0] = 0;
+      clib_memcpy (o->data + 1, c->client_identifier,
                   vec_len (c->client_identifier));
       o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
     }
@@ -884,15 +887,18 @@ dhcp_client_process (vlib_main_t * vm,
          break;
 
        case ~0:
-          /* *INDENT-OFF* */
-          DHCP_INFO ("timeout");
-         pool_foreach (c, dcm->clients,
-          ({
-            timeout = dhcp_client_sm (now, timeout,
-                                      (uword) (c - dcm->clients));
-          }));
-          /* *INDENT-ON* */
-         if (pool_elts (dcm->clients) == 0)
+         if (pool_elts (dcm->clients))
+           {
+             DHCP_INFO ("timeout");
+              /* *INDENT-OFF* */
+              pool_foreach (c, dcm->clients,
+              ({
+                timeout = dhcp_client_sm (now, timeout,
+                                          (uword) (c - dcm->clients));
+              }));
+              /* *INDENT-ON* */
+           }
+         else
            timeout = 100.0;
          break;
        }
@@ -1105,15 +1111,13 @@ dhcp_client_config (u32 is_add,
       vec_free (a->option_55_data);
 
       if (is_add)
-       clib_warning ("dhcp client already enabled on intf_idx %d",
-                     sw_if_index);
+       DHCP_INFO ("dhcp client already enabled on intf_idx %d", sw_if_index);
       else
-       clib_warning ("dhcp client not enabled on on intf_idx %d",
-                     sw_if_index);
+       DHCP_INFO ("not enabled on on intf_idx %d", sw_if_index);
       break;
 
     default:
-      clib_warning ("dhcp_client_add_del returned %d", rv);
+      DHCP_INFO ("dhcp_client_add_del returned %d", rv);
     }
 
   return rv;
@@ -1172,7 +1176,7 @@ dhcp_client_set_command_fn (vlib_main_t * vm,
   a->is_add = is_add;
   a->sw_if_index = sw_if_index;
   a->hostname = hostname;
-  a->client_identifier = format (0, "vpe 1.0%c", 0);
+  a->client_identifier = format (0, "vpp 1.1%c", 0);
   a->set_broadcast_flag = set_broadcast_flag;
 
   /*
@@ -1254,6 +1258,7 @@ dhcp_client_init (vlib_main_t * vm)
   dcm->seed = (u32) clib_cpu_time_now ();
 
   dhcp_logger = vlib_log_register_class ("dhcp", "client");
+  DHCP_INFO ("plugin initialized");
 
   return 0;
 }