@@ -49,8 +49,6 @@ static uint8_t classless_route[sizeof(classless_route_prefix) + sizeof(server_ip
4949static_assert (DP_VIRTSVC_MAX <= UINT8_MAX + 1 , "Number of virtual services can be higher than supported link-local subnet size" );
5050#endif
5151
52- #define DHCP_OPT_HOSTNAME 12
53-
5452static int dhcp_node_init (__rte_unused const struct rte_graph * graph , __rte_unused struct rte_node * node )
5553{
5654 server_ip = htonl (dp_get_gw_ip4 ());
@@ -89,11 +87,10 @@ static __rte_always_inline int add_dhcp_option(uint8_t **pos_ptr, uint8_t *end,
8987static __rte_always_inline int add_dhcp_options (struct dp_dhcp_header * dhcp_hdr ,
9088 uint8_t msg_type ,
9189 enum dp_pxe_mode pxe_mode ,
92- const char * hostname )
90+ const struct dp_port * port )
9391{
9492 uint8_t * pos = dhcp_hdr -> options ;
9593 uint8_t * end = pos + DHCP_MAX_OPTIONS_LEN ;
96- uint8_t hostname_len ;
9794 const struct dp_conf_dhcp_dns * dhcp_dns = dp_conf_get_dhcp_dns ();
9895
9996 if (DP_FAILED (add_dhcp_option (& pos , end , DHCP_OPT_MESSAGE_TYPE , & msg_type , sizeof (msg_type )))
@@ -113,12 +110,9 @@ static __rte_always_inline int add_dhcp_options(struct dp_dhcp_header *dhcp_hdr,
113110 if (DP_FAILED (add_dhcp_option (& pos , end , DHCP_OPT_DNS , dhcp_dns -> array , dhcp_dns -> len )))
114111 return DP_ERROR ;
115112
116- if (hostname && hostname [0 ] != '\0' ) {
117- hostname_len = (uint8_t )strnlen (hostname , DP_IFACE_HOSTNAME_MAX_LEN - 1 );
118-
119- if (DP_FAILED (add_dhcp_option (& pos , end , DHCP_OPT_HOSTNAME , hostname , hostname_len )))
113+ if (port -> iface .hostname_len > 0 )
114+ if (DP_FAILED (add_dhcp_option (& pos , end , DHCP_OPT_HOSTNAME , port -> iface .cfg .hostname , (u_int8_t )port -> iface .hostname_len )))
120115 return DP_ERROR ;
121- }
122116
123117 if (pos >= end )
124118 return DP_ERROR ;
@@ -190,7 +184,6 @@ static __rte_always_inline rte_edge_t get_next_index(struct rte_node *node, stru
190184 rte_be32_t pxe_srv_ip ;
191185 char pxe_srv_ip_str [INET6_ADDRSTRLEN ];
192186 uint8_t response_type ;
193- const char * hostname ;
194187
195188 incoming_eth_hdr = rte_pktmbuf_mtod (m , struct rte_ether_hdr * );
196189 incoming_ipv4_hdr = (struct rte_ipv4_hdr * )(incoming_eth_hdr + 1 );
@@ -274,8 +267,7 @@ static __rte_always_inline rte_edge_t get_next_index(struct rte_node *node, stru
274267 dhcp_hdr -> siaddr = server_ip ;
275268 }
276269
277- hostname = port -> iface .cfg .hostname ;
278- options_len = add_dhcp_options (dhcp_hdr , response_type , pxe_mode , hostname );
270+ options_len = add_dhcp_options (dhcp_hdr , response_type , pxe_mode , port );
279271 if (DP_FAILED (options_len )) {
280272 DPNODE_LOG_WARNING (node , "DHCP response options too large for a packet" );
281273 return DHCP_NEXT_DROP ;
0 commit comments