39 #include <sys/types.h>
41 #include <sys/socket.h>
44 #include <sys/ioctl.h>
45 #include <sys/param.h>
46 #include <netinet/in.h>
47 #include <net/ethernet.h>
48 #include <arpa/inet.h>
62 #include <qb/qbdefs.h>
63 #include <qb/qbloop.h>
66 #include <libnozzle.h>
83 #define MSG_NOSIGNAL 0
87 static int setup_nozzle(
void *knet_context);
91 #define CFG_INTERFACE_STATUS_MAX_LEN 512
107 unsigned int msg_len,
113 unsigned int link_no);
141 const char *
function,
177 #ifdef HAVE_LIBNOZZLE
181 char *nozzle_macaddr;
182 nozzle_t nozzle_handle;
199 static int totemknet_configure_compression (
203 static void totemknet_start_merge_detect_timeout(
206 static void totemknet_stop_merge_detect_timeout(
209 static void log_flush_messages (
217 res = pthread_mutex_init(&instance->
log_mutex, NULL);
224 #define knet_log_printf_lock(level, subsys, function, file, line, format, args...) \
226 (void)pthread_mutex_lock(&instance->log_mutex); \
227 instance->totemknet_log_printf ( \
228 level, subsys, function, file, line, \
229 (const char *)format, ##args); \
230 (void)pthread_mutex_unlock(&instance->log_mutex); \
233 #define knet_log_printf(level, format, args...) \
235 knet_log_printf_lock ( \
236 level, instance->totemknet_subsys_id, \
237 __FUNCTION__, __FILE__, __LINE__, \
238 (const char *)format, ##args); \
241 #define libknet_log_printf(level, format, args...) \
243 knet_log_printf_lock ( \
244 level, instance->knet_subsys_id, \
245 __FUNCTION__, "libknet.h", __LINE__, \
246 (const char *)format, ##args); \
249 #define KNET_LOGSYS_PERROR(err_num, level, fmt, args...) \
251 char _error_str[LOGSYS_MAX_PERROR_MSG_LEN]; \
252 const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str)); \
253 instance->totemknet_log_printf ( \
254 level, instance->totemknet_subsys_id, \
255 __FUNCTION__, __FILE__, __LINE__, \
256 fmt ": %s (%d)", ##args, _error_ptr, err_num); \
260 #ifdef HAVE_LIBNOZZLE
261 static inline int is_ether_addr_multicast(
const uint8_t *
addr)
263 return (
addr[0] & 0x01);
265 static inline int is_ether_addr_zero(
const uint8_t *
addr)
270 static int ether_host_filter_fn(
void *private_data,
271 const unsigned char *outdata,
274 knet_node_id_t this_host_id,
275 knet_node_id_t src_host_id,
277 knet_node_id_t *dst_host_ids,
278 size_t *dst_host_ids_entries)
280 struct ether_header *eth_h = (
struct ether_header *)outdata;
281 uint8_t *dst_mac = (uint8_t *)eth_h->ether_dhost;
282 uint16_t dst_host_id;
284 if (is_ether_addr_zero(dst_mac))
287 if (is_ether_addr_multicast(dst_mac)) {
291 memmove(&dst_host_id, &dst_mac[4], 2);
293 dst_host_ids[0] = ntohs(dst_host_id);
294 *dst_host_ids_entries = 1;
300 static int dst_host_filter_callback_fn(
void *private_data,
301 const unsigned char *outdata,
304 knet_node_id_t this_host_id,
305 knet_node_id_t src_host_id,
307 knet_node_id_t *dst_host_ids,
308 size_t *dst_host_ids_entries)
313 #ifdef HAVE_LIBNOZZLE
315 return ether_host_filter_fn(private_data,
316 outdata, outdata_len,
318 this_host_id, src_host_id,
321 dst_host_ids_entries);
326 *dst_host_ids_entries = 1;
330 *dst_host_ids_entries = 0;
336 static void socket_error_callback_fn(
void *private_data,
int datafd, int8_t channel, uint8_t tx_rx,
int error,
int errorno)
341 if ((error == -1 && errorno != EAGAIN) || (error == 0)) {
342 knet_handle_remove_datafd(instance->
knet_handle, datafd);
346 static void host_change_callback_fn(
void *private_data, knet_node_id_t host_id, uint8_t reachable, uint8_t remote, uint8_t external)
354 static void pmtu_change_callback_fn(
void *private_data,
unsigned int data_mtu)
365 const char *cipher_type,
366 const char *hash_type)
372 static inline void ucast_sendmsg (
376 unsigned int msg_len)
380 struct msghdr msg_ucast;
385 iovec.iov_base = (
void *)msg;
386 iovec.iov_len = msg_len;
391 memset(&msg_ucast, 0,
sizeof(msg_ucast));
392 msg_ucast.msg_iov = (
void *)&iovec;
393 msg_ucast.msg_iovlen = 1;
394 #ifdef HAVE_MSGHDR_CONTROL
395 msg_ucast.msg_control = 0;
397 #ifdef HAVE_MSGHDR_CONTROLLEN
398 msg_ucast.msg_controllen = 0;
400 #ifdef HAVE_MSGHDR_FLAGS
401 msg_ucast.msg_flags = 0;
403 #ifdef HAVE_MSGHDR_ACCRIGHTS
404 msg_ucast.msg_accrights = NULL;
406 #ifdef HAVE_MSGHDR_ACCRIGHTSLEN
407 msg_ucast.msg_accrightslen = 0;
418 "sendmsg(ucast) failed (non-critical)");
422 static inline void mcast_sendmsg (
425 unsigned int msg_len,
430 struct msghdr msg_mcast;
433 iovec.iov_base = (
void *)msg;
434 iovec.iov_len = msg_len;
441 memset(&msg_mcast, 0,
sizeof(msg_mcast));
442 msg_mcast.msg_iov = (
void *)&iovec;
443 msg_mcast.msg_iovlen = 1;
444 #ifdef HAVE_MSGHDR_CONTROL
445 msg_mcast.msg_control = 0;
447 #ifdef HAVE_MSGHDR_CONTROLLEN
448 msg_mcast.msg_controllen = 0;
450 #ifdef HAVE_MSGHDR_FLAGS
451 msg_mcast.msg_flags = 0;
453 #ifdef HAVE_MSGHDR_ACCRIGHTS
454 msg_mcast.msg_accrights = NULL;
456 #ifdef HAVE_MSGHDR_ACCRIGHTSLEN
457 msg_mcast.msg_accrightslen = 0;
477 static int node_compare(
const void *aptr,
const void *bptr)
481 a = *(uint16_t *)aptr;
482 b = *(uint16_t *)bptr;
487 #ifndef OWN_INDEX_NONE
488 #define OWN_INDEX_NONE -1
493 unsigned int *iface_count)
496 struct knet_link_status link_status;
497 knet_node_id_t host_list[KNET_MAX_HOST];
498 uint8_t link_list[KNET_MAX_LINK];
513 res = knet_host_get_host_list(instance->
knet_handle,
514 host_list, &num_hosts);
518 qsort(host_list, num_hosts,
sizeof(uint16_t), node_compare);
520 for (j=0; j<num_hosts; j++) {
538 for (j=0; j<num_hosts; j++) {
543 res = knet_link_get_link_list(instance->
knet_handle,
544 host_list[j], link_list, &num_links);
550 for (i=0; i < num_links; i++) {
565 sizeof(link_status));
567 ptr[j] =
'0' + (link_status.enabled |
568 link_status.connected<<1 |
569 link_status.dynconnected<<2);
573 "totemknet_ifaces_get: Cannot get link status: %s", strerror(errno));
592 static knet_node_id_t nodes[KNET_MAX_HOST];
593 uint8_t links[KNET_MAX_LINK];
605 res = knet_handle_setfwd(instance->
knet_handle, 0);
610 res = knet_host_get_host_list(instance->
knet_handle, nodes, &num_nodes);
618 for (i=0; i<num_nodes; i++) {
620 res = knet_link_get_link_list(instance->
knet_handle, nodes[i], links, &num_links);
625 for (j=0; j<num_links; j++) {
626 res = knet_link_set_enable(instance->
knet_handle, nodes[i], links[j], 0);
630 res = knet_link_clear_config(instance->
knet_handle, nodes[i], links[j]);
635 res = knet_host_remove(instance->
knet_handle, nodes[i]);
647 totemknet_stop_merge_detect_timeout(instance);
649 log_flush_messages(instance);
654 (void)pthread_mutex_destroy(&instance->
log_mutex);
659 static int log_deliver_fn (
665 char buffer[
sizeof(
struct knet_log_msg)*4];
666 char *bufptr = buffer;
670 len = read(fd, buffer,
sizeof(buffer));
672 struct knet_log_msg *msg = (
struct knet_log_msg *)bufptr;
673 switch (msg->msglevel) {
676 knet_log_get_subsystem_name(msg->subsystem),
681 knet_log_get_subsystem_name(msg->subsystem),
686 knet_log_get_subsystem_name(msg->subsystem),
691 knet_log_get_subsystem_name(msg->subsystem),
695 bufptr +=
sizeof(
struct knet_log_msg);
696 done +=
sizeof(
struct knet_log_msg);
701 static int data_deliver_fn (
707 struct msghdr msg_hdr;
708 struct iovec iov_recv;
711 int truncated_packet;
714 iov_recv.iov_len = KNET_MAX_PACKET_SIZE;
717 msg_hdr.msg_namelen =
sizeof (
struct sockaddr_storage);
718 msg_hdr.msg_iov = &iov_recv;
719 msg_hdr.msg_iovlen = 1;
720 #ifdef HAVE_MSGHDR_CONTROL
721 msg_hdr.msg_control = 0;
723 #ifdef HAVE_MSGHDR_CONTROLLEN
724 msg_hdr.msg_controllen = 0;
726 #ifdef HAVE_MSGHDR_FLAGS
727 msg_hdr.msg_flags = 0;
729 #ifdef HAVE_MSGHDR_ACCRIGHTS
730 msg_hdr.msg_accrights = NULL;
732 #ifdef HAVE_MSGHDR_ACCRIGHTSLEN
733 msg_hdr.msg_accrightslen = 0;
736 msg_len = recvmsg (fd, &msg_hdr,
MSG_NOSIGNAL | MSG_DONTWAIT);
741 truncated_packet = 0;
743 #ifdef HAVE_MSGHDR_FLAGS
744 if (msg_hdr.msg_flags & MSG_TRUNC) {
745 truncated_packet = 1;
752 if (bytes_received == KNET_MAX_PACKET_SIZE) {
753 truncated_packet = 1;
757 if (truncated_packet) {
759 "Received too big message. This may be because something bad is happening"
760 "on the network (attack?), or you tried join more nodes than corosync is"
761 "compiled with (%u) or bug in the code (bad estimation of "
778 static void timer_function_netif_check_timeout (
796 #ifdef HAVE_KNET_ACCESS_LIST
812 static void totemknet_refresh_config(
814 const char *key_name,
823 knet_node_id_t host_ids[KNET_MAX_HOST];
834 if (
icmap_get_uint8(
"config.totemconfig_reload_in_progress", &reloading) ==
CS_OK && reloading) {
838 knet_set_access_list_config(instance);
851 err = knet_host_get_host_list(instance->
knet_handle, host_ids, &num_nodes);
856 for (i=0; i<num_nodes; i++) {
862 err = knet_link_set_ping_timers(instance->
knet_handle, host_ids[i], link_no,
869 err = knet_link_set_pong_count(instance->
knet_handle, host_ids[i], link_no,
874 err = knet_link_set_priority(instance->
knet_handle, host_ids[i], link_no,
895 totemknet_refresh_config,
901 totemknet_refresh_config,
903 &icmap_track_reload);
910 struct knet_handle_crypto_cfg crypto_cfg;
920 #ifdef HAVE_KNET_CRYPTO_RECONF
923 crypto_cfg.crypto_model,
924 crypto_cfg.crypto_cipher_type,
925 crypto_cfg.crypto_hash_type,
931 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_ALLOW_CLEAR_TRAFFIC);
949 crypto_cfg.crypto_model,
950 crypto_cfg.crypto_cipher_type,
951 crypto_cfg.crypto_hash_type
954 res = knet_handle_crypto(instance->
knet_handle, &crypto_cfg);
974 qb_loop_t *poll_handle,
983 unsigned int msg_len,
986 void (*iface_change_fn) (
989 unsigned int link_no),
991 void (*mtu_changed) (
995 void (*target_set_completed) (
1004 if (instance == NULL) {
1008 totemknet_instance_initialize (instance);
1058 if (fcntl(instance->
logpipes[0], F_SETFL, O_NONBLOCK) == -1 ||
1059 fcntl(instance->
logpipes[1], F_SETFL, O_NONBLOCK) == -1) {
1065 #if !defined(KNET_API_VER) || (KNET_API_VER == 1)
1068 #if KNET_API_VER == 2
1077 knet_set_access_list_config(instance);
1083 res = knet_handle_enable_filter(instance->
knet_handle, instance, dst_host_filter_callback_fn);
1087 res = knet_handle_enable_sock_notify(instance->
knet_handle, instance, socket_error_callback_fn);
1091 res = knet_host_enable_status_change_notify(instance->
knet_handle, instance, host_change_callback_fn);
1095 res = knet_handle_enable_pmtud_notify(instance->
knet_handle, instance, pmtu_change_callback_fn);
1105 knet_log_printf(LOG_DEBUG,
"knet_handle_add_datafd failed: %s", strerror(errno));
1110 #ifdef HAVE_KNET_CRYPTO_RECONF
1112 res = totemknet_set_knet_crypto(instance);
1116 knet_log_printf(LOG_DEBUG,
"knet_handle_crypto_use_config failed: %s", strerror(errno));
1123 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_DISALLOW_CLEAR_TRAFFIC);
1125 knet_log_printf(LOG_DEBUG,
"knet_handle_crypto_rx_clear_traffic (DISALLOW) failed: %s", strerror(errno));
1130 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_ALLOW_CLEAR_TRAFFIC);
1132 knet_log_printf(LOG_DEBUG,
"knet_handle_crypto_rx_clear_traffic (ALLOW) failed: %s", strerror(errno));
1138 res = totemknet_set_knet_crypto(instance);
1154 instance->
link_mode = KNET_LINK_POLICY_PASSIVE;
1156 instance->
link_mode = KNET_LINK_POLICY_ACTIVE;
1159 instance->
link_mode = KNET_LINK_POLICY_RR;
1172 POLLIN, instance, log_deliver_fn);
1177 POLLIN, instance, data_deliver_fn);
1185 100*QB_TIME_NS_IN_MSEC,
1187 timer_function_netif_check_timeout,
1188 &instance->timer_netif_check_timeout);
1190 totemknet_start_merge_detect_timeout(instance);
1193 totemknet_add_config_notifications(instance);
1204 log_flush_messages(instance);
1212 return malloc(KNET_MAX_PACKET_SIZE + 512);
1222 int processor_count)
1240 unsigned int msg_len)
1245 ucast_sendmsg (instance, &instance->
token_target, msg, msg_len);
1252 unsigned int msg_len)
1257 mcast_sendmsg (instance, msg, msg_len, 0);
1265 unsigned int msg_len)
1270 mcast_sendmsg (instance, msg, msg_len, 1);
1313 struct msghdr msg_hdr;
1314 struct iovec iov_recv;
1317 int msg_processed = 0;
1320 iov_recv.iov_len = KNET_MAX_PACKET_SIZE;
1323 msg_hdr.msg_namelen =
sizeof (
struct sockaddr_storage);
1324 msg_hdr.msg_iov = &iov_recv;
1325 msg_hdr.msg_iovlen = 1;
1326 #ifdef HAVE_MSGHDR_CONTROL
1327 msg_hdr.msg_control = 0;
1329 #ifdef HAVE_MSGHDR_CONTROLLEN
1330 msg_hdr.msg_controllen = 0;
1332 #ifdef HAVE_MSGHDR_FLAGS
1333 msg_hdr.msg_flags = 0;
1335 #ifdef HAVE_MSGHDR_ACCRIGHTS
1336 msg_msg_hdr.msg_accrights = NULL;
1338 #ifdef HAVE_MSGHDR_ACCRIGHTSLEN
1339 msg_msg_hdr.msg_accrightslen = 0;
1344 ufd.events = POLLIN;
1345 nfds = poll (&ufd, 1, 0);
1346 if (nfds == 1 && ufd.revents & POLLIN) {
1354 }
while (nfds == 1);
1356 return (msg_processed);
1361 unsigned short ip_port,
1362 unsigned int iface_no)
1384 int port = instance->
ip_port[link_no];
1385 struct sockaddr_storage remote_ss;
1386 struct sockaddr_storage local_ss;
1390 knet_node_id_t host_ids[KNET_MAX_HOST];
1391 size_t num_host_ids;
1409 err = knet_host_get_host_list(instance->
knet_handle, host_ids, &num_host_ids);
1414 for (i=0; i<num_host_ids; i++) {
1415 if (host_ids[i] == member->
nodeid) {
1422 if (err != 0 && errno != EEXIST) {
1438 memset(&local_ss, 0,
sizeof(local_ss));
1439 memset(&remote_ss, 0,
sizeof(remote_ss));
1448 KNET_TRANSPORT_LOOPBACK,
1449 &local_ss, &remote_ss, KNET_LINK_FLAG_TRAFFICHIPRIO);
1454 &local_ss, &remote_ss, KNET_LINK_FLAG_TRAFFICHIPRIO);
1505 uint8_t link_list[KNET_MAX_LINK];
1532 res = knet_link_get_link_list(instance->
knet_handle,
1538 if (num_links == 0) {
1551 static int totemknet_configure_compression (
1556 struct knet_handle_compress_cfg compress_cfg;
1565 res = knet_handle_compress(instance->
knet_handle, &compress_cfg);
1581 #ifdef HAVE_LIBNOZZLE
1585 (void)setup_nozzle(instance);
1591 res = totemknet_set_knet_crypto(instance);
1607 #ifdef HAVE_KNET_CRYPTO_RECONF
1610 int config_to_clear;
1611 struct knet_handle_crypto_cfg crypto_cfg;
1624 res = knet_handle_crypto_use_config(instance->
knet_handle, config_to_use);
1638 strcpy(crypto_cfg.crypto_model,
"none");
1639 strcpy(crypto_cfg.crypto_cipher_type,
"none");
1640 strcpy(crypto_cfg.crypto_hash_type,
"none");
1641 res = knet_handle_crypto_set_config(instance->
knet_handle, &crypto_cfg, config_to_clear);
1651 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_DISALLOW_CLEAR_TRAFFIC);
1666 (void) knet_handle_clear_stats(instance->
knet_handle, KNET_CLEARSTATS_HANDLE_AND_LINK);
1671 knet_node_id_t node, uint8_t link_no,
1672 struct knet_link_status *status)
1708 struct knet_handle_stats *stats)
1725 static void timer_function_merge_detect_timeout (
1736 totemknet_start_merge_detect_timeout(instance);
1739 static void totemknet_start_merge_detect_timeout(
1748 timer_function_merge_detect_timeout,
1749 &instance->timer_merge_detect_timeout);
1753 static void totemknet_stop_merge_detect_timeout(
1772 pfd.events = POLLIN;
1775 if ((poll(&pfd, 1, 0) > 0) &&
1776 (pfd.revents & POLLIN) &&
1777 (log_deliver_fn(instance->
logpipes[0], POLLIN, instance) == 0)) {
1786 #ifdef HAVE_LIBNOZZLE
1787 #define NOZZLE_NAME "nozzle.name"
1788 #define NOZZLE_IPADDR "nozzle.ipaddr"
1789 #define NOZZLE_PREFIX "nozzle.ipprefix"
1790 #define NOZZLE_MACADDR "nozzle.macaddr"
1792 #define NOZZLE_CHANNEL 1
1798 char filename[PATH_MAX + FILENAME_MAX + 1];
1799 static char updown_dirname[PATH_MAX + FILENAME_MAX + 1];
1801 const char *dirname_res;
1806 res = snprintf(filename,
sizeof(filename),
"%s",
1808 if (res >=
sizeof(filename)) {
1813 dirname_res = dirname(filename);
1815 res = snprintf(updown_dirname,
sizeof(updown_dirname),
"%s/%s",
1816 dirname_res,
"updown.d");
1817 if (res >=
sizeof(updown_dirname)) {
1821 return updown_dirname;
1833 res = nozzle_run_updown(instance->nozzle_handle,
type, &exec_string);
1834 if (res == -1 && errno != ENOENT) {
1836 }
else if (res == -2) {
1851 const char *input_addr,
1852 const char *prefix,
int nodeid,
1853 char *output_addr,
size_t output_len)
1857 int max_prefix = 64;
1858 uint32_t nodeid_mask;
1860 uint32_t masked_nodeid;
1861 struct in_addr *
addr;
1864 coloncolon = strstr(input_addr,
"::");
1869 bits = atoi(prefix);
1870 if (bits < 8 || bits > max_prefix) {
1877 memcpy(output_addr, input_addr, coloncolon-input_addr);
1878 sprintf(output_addr + (coloncolon-input_addr),
"::%x",
nodeid);
1885 nodeid_mask = UINT32_MAX & ((1<<(32 - bits)) - 1);
1886 addr_mask = UINT32_MAX ^ nodeid_mask;
1887 masked_nodeid =
nodeid & nodeid_mask;
1893 addr = (
struct in_addr *)&totemip.addr;
1894 addr->s_addr &= htonl(addr_mask);
1895 addr->s_addr |= htonl(masked_nodeid);
1897 inet_ntop(AF_INET,
addr, output_addr, output_len);
1901 static int create_nozzle_device(
void *knet_context,
const char *name,
1902 const char *ipaddr,
const char *prefix,
1903 const char *macaddr)
1906 char device_name[IFNAMSIZ+1];
1907 size_t size = IFNAMSIZ;
1908 int8_t channel = NOZZLE_CHANNEL;
1909 nozzle_t nozzle_dev;
1913 char parsed_ipaddr[INET6_ADDRSTRLEN];
1916 memset(device_name, 0, size);
1917 memset(&mac, 0,
sizeof(mac));
1918 strncpy(device_name, name, size);
1923 nozzle_dev = nozzle_open(device_name, size, updown_dir);
1928 instance->nozzle_handle = nozzle_dev;
1930 if (nozzle_set_mac(nozzle_dev, macaddr) < 0) {
1935 if (reparse_nozzle_ip_address(instance, ipaddr, prefix, instance->
our_nodeid, parsed_ipaddr,
sizeof(parsed_ipaddr))) {
1940 if (nozzle_add_ip(nozzle_dev, parsed_ipaddr, prefix) < 0) {
1945 nozzle_fd = nozzle_get_fd(nozzle_dev);
1948 res = knet_handle_add_datafd(instance->
knet_handle, &nozzle_fd, &channel);
1954 run_nozzle_script(instance, NOZZLE_PREUP,
"pre-up");
1956 res = nozzle_set_up(nozzle_dev);
1961 run_nozzle_script(instance, NOZZLE_UP,
"up");
1966 nozzle_close(nozzle_dev);
1976 res = knet_handle_get_datafd(instance->
knet_handle, NOZZLE_CHANNEL, &datafd);
1982 res = knet_handle_remove_datafd(instance->
knet_handle, datafd);
1988 run_nozzle_script(instance, NOZZLE_DOWN,
"pre-down");
1989 res = nozzle_set_down(instance->nozzle_handle);
1994 run_nozzle_script(instance, NOZZLE_POSTDOWN,
"post-down");
1996 res = nozzle_close(instance->nozzle_handle);
2007 free(instance->nozzle_name);
2008 free(instance->nozzle_ipaddr);
2009 free(instance->nozzle_prefix);
2010 free(instance->nozzle_macaddr);
2012 instance->nozzle_name = instance->nozzle_ipaddr = instance->nozzle_prefix =
2013 instance->nozzle_macaddr = NULL;
2019 char *ipaddr_str = NULL;
2020 char *name_str = NULL;
2021 char *prefix_str = NULL;
2022 char *macaddr_str = NULL;
2039 remove_nozzle_device(instance);
2040 free_nozzle(instance);
2059 if (macaddr_str && strlen(macaddr_str) != 17) {
2064 macaddr_str = (
char*)
"54:54:01:00:00:00";
2067 if (instance->nozzle_name &&
2068 (strcmp(name_str, instance->nozzle_name) == 0) &&
2069 (strcmp(ipaddr_str, instance->nozzle_ipaddr) == 0) &&
2070 (strcmp(prefix_str, instance->nozzle_prefix) == 0) &&
2071 (instance->nozzle_macaddr == NULL ||
2072 strcmp(macaddr_str, instance->nozzle_macaddr) == 0)) {
2079 memcpy(mac, macaddr_str, 12);
2080 snprintf(mac+12,
sizeof(mac) - 13,
"%02x:%02x",
2085 if (name_res ==
CS_OK && name_str) {
2087 if (instance->nozzle_name) {
2088 remove_nozzle_device(instance);
2089 free_nozzle(instance);
2092 res = create_nozzle_device(
knet_context, name_str, ipaddr_str, prefix_str,
2095 instance->nozzle_name = strdup(name_str);
2096 instance->nozzle_ipaddr = strdup(ipaddr_str);
2097 instance->nozzle_prefix = strdup(prefix_str);
2098 instance->nozzle_macaddr = strdup(macaddr_str);
2099 if (!instance->nozzle_name || !instance->nozzle_ipaddr ||
2100 !instance->nozzle_prefix) {
2107 free_nozzle(instance);
2115 if (macaddr_res ==
CS_OK) {
2121 #endif // HAVE_LIBNOZZLE