Lines Matching refs:nt
128 static void netconsole_target_get(struct netconsole_target *nt) in netconsole_target_get() argument
130 if (config_item_name(&nt->item)) in netconsole_target_get()
131 config_item_get(&nt->item); in netconsole_target_get()
134 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
136 if (config_item_name(&nt->item)) in netconsole_target_put()
137 config_item_put(&nt->item); in netconsole_target_put()
155 static void netconsole_target_get(struct netconsole_target *nt) in netconsole_target_get() argument
159 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
169 struct netconsole_target *nt; in alloc_param_target() local
175 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in alloc_param_target()
176 if (!nt) in alloc_param_target()
179 nt->np.name = "netconsole"; in alloc_param_target()
180 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); in alloc_param_target()
181 nt->np.local_port = 6665; in alloc_param_target()
182 nt->np.remote_port = 6666; in alloc_param_target()
183 eth_broadcast_addr(nt->np.remote_mac); in alloc_param_target()
186 nt->extended = true; in alloc_param_target()
191 err = netpoll_parse_options(&nt->np, target_config); in alloc_param_target()
195 err = netpoll_setup(&nt->np); in alloc_param_target()
199 nt->enabled = true; in alloc_param_target()
201 return nt; in alloc_param_target()
204 kfree(nt); in alloc_param_target()
209 static void free_param_target(struct netconsole_target *nt) in free_param_target() argument
211 netpoll_cleanup(&nt->np); in free_param_target()
212 kfree(nt); in free_param_target()
273 struct netconsole_target *nt = to_target(item); in local_ip_show() local
275 if (nt->np.ipv6) in local_ip_show()
276 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); in local_ip_show()
278 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); in local_ip_show()
283 struct netconsole_target *nt = to_target(item); in remote_ip_show() local
285 if (nt->np.ipv6) in remote_ip_show()
286 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); in remote_ip_show()
288 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); in remote_ip_show()
314 struct netconsole_target *nt = to_target(item); in enabled_store() local
327 if ((bool)enabled == nt->enabled) { in enabled_store()
329 nt->enabled ? "started" : "stopped"); in enabled_store()
334 if (nt->extended && !(netconsole_ext.flags & CON_ENABLED)) { in enabled_store()
343 netpoll_print_options(&nt->np); in enabled_store()
345 err = netpoll_setup(&nt->np); in enabled_store()
356 nt->enabled = false; in enabled_store()
358 netpoll_cleanup(&nt->np); in enabled_store()
361 nt->enabled = enabled; in enabled_store()
373 struct netconsole_target *nt = to_target(item); in extended_store() local
378 if (nt->enabled) { in extended_store()
380 config_item_name(&nt->item)); in extended_store()
393 nt->extended = extended; in extended_store()
405 struct netconsole_target *nt = to_target(item); in dev_name_store() local
409 if (nt->enabled) { in dev_name_store()
411 config_item_name(&nt->item)); in dev_name_store()
416 strlcpy(nt->np.dev_name, buf, IFNAMSIZ); in dev_name_store()
419 len = strnlen(nt->np.dev_name, IFNAMSIZ); in dev_name_store()
420 if (nt->np.dev_name[len - 1] == '\n') in dev_name_store()
421 nt->np.dev_name[len - 1] = '\0'; in dev_name_store()
430 struct netconsole_target *nt = to_target(item); in local_port_store() local
434 if (nt->enabled) { in local_port_store()
436 config_item_name(&nt->item)); in local_port_store()
440 rv = kstrtou16(buf, 10, &nt->np.local_port); in local_port_store()
453 struct netconsole_target *nt = to_target(item); in remote_port_store() local
457 if (nt->enabled) { in remote_port_store()
459 config_item_name(&nt->item)); in remote_port_store()
463 rv = kstrtou16(buf, 10, &nt->np.remote_port); in remote_port_store()
476 struct netconsole_target *nt = to_target(item); in local_ip_store() local
479 if (nt->enabled) { in local_ip_store()
481 config_item_name(&nt->item)); in local_ip_store()
487 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { in local_ip_store()
492 nt->np.ipv6 = true; in local_ip_store()
496 if (!nt->np.ipv6) { in local_ip_store()
497 nt->np.local_ip.ip = in_aton(buf); in local_ip_store()
512 struct netconsole_target *nt = to_target(item); in remote_ip_store() local
515 if (nt->enabled) { in remote_ip_store()
517 config_item_name(&nt->item)); in remote_ip_store()
523 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { in remote_ip_store()
528 nt->np.ipv6 = true; in remote_ip_store()
532 if (!nt->np.ipv6) { in remote_ip_store()
533 nt->np.remote_ip.ip = in_aton(buf); in remote_ip_store()
548 struct netconsole_target *nt = to_target(item); in remote_mac_store() local
552 if (nt->enabled) { in remote_mac_store()
554 config_item_name(&nt->item)); in remote_mac_store()
562 memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); in remote_mac_store()
621 struct netconsole_target *nt; in make_netconsole_target() local
627 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in make_netconsole_target()
628 if (!nt) in make_netconsole_target()
631 nt->np.name = "netconsole"; in make_netconsole_target()
632 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); in make_netconsole_target()
633 nt->np.local_port = 6665; in make_netconsole_target()
634 nt->np.remote_port = 6666; in make_netconsole_target()
635 eth_broadcast_addr(nt->np.remote_mac); in make_netconsole_target()
638 config_item_init_type_name(&nt->item, name, &netconsole_target_type); in make_netconsole_target()
642 list_add(&nt->list, &target_list); in make_netconsole_target()
645 return &nt->item; in make_netconsole_target()
652 struct netconsole_target *nt = to_target(item); in drop_netconsole_target() local
655 list_del(&nt->list); in drop_netconsole_target()
662 if (nt->enabled) in drop_netconsole_target()
663 netpoll_cleanup(&nt->np); in drop_netconsole_target()
665 config_item_put(&nt->item); in drop_netconsole_target()
695 struct netconsole_target *nt; in netconsole_netdev_event() local
705 list_for_each_entry(nt, &target_list, list) { in netconsole_netdev_event()
706 netconsole_target_get(nt); in netconsole_netdev_event()
707 if (nt->np.dev == dev) { in netconsole_netdev_event()
710 strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); in netconsole_netdev_event()
720 __netpoll_cleanup(&nt->np); in netconsole_netdev_event()
723 dev_put(nt->np.dev); in netconsole_netdev_event()
724 nt->np.dev = NULL; in netconsole_netdev_event()
725 nt->enabled = false; in netconsole_netdev_event()
727 netconsole_target_put(nt); in netconsole_netdev_event()
731 netconsole_target_put(nt); in netconsole_netdev_event()
769 static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg, in send_ext_msg_udp() argument
778 netpoll_send_udp(&nt->np, msg, msg_len); in send_ext_msg_udp()
813 netpoll_send_udp(&nt->np, buf, this_header + this_chunk); in send_ext_msg_udp()
822 struct netconsole_target *nt; in write_ext_msg() local
829 list_for_each_entry(nt, &target_list, list) in write_ext_msg()
830 if (nt->extended && nt->enabled && netif_running(nt->np.dev)) in write_ext_msg()
831 send_ext_msg_udp(nt, msg, len); in write_ext_msg()
839 struct netconsole_target *nt; in write_msg() local
849 list_for_each_entry(nt, &target_list, list) { in write_msg()
850 if (!nt->extended && nt->enabled && netif_running(nt->np.dev)) { in write_msg()
860 netpoll_send_udp(&nt->np, tmp, frag); in write_msg()
884 struct netconsole_target *nt, *tmp; in init_netconsole() local
891 nt = alloc_param_target(target_config); in init_netconsole()
892 if (IS_ERR(nt)) { in init_netconsole()
893 err = PTR_ERR(nt); in init_netconsole()
897 if (nt->extended) in init_netconsole()
904 list_add(&nt->list, &target_list); in init_netconsole()
935 list_for_each_entry_safe(nt, tmp, &target_list, list) { in init_netconsole()
936 list_del(&nt->list); in init_netconsole()
937 free_param_target(nt); in init_netconsole()
945 struct netconsole_target *nt, *tmp; in cleanup_netconsole() local
960 list_for_each_entry_safe(nt, tmp, &target_list, list) { in cleanup_netconsole()
961 list_del(&nt->list); in cleanup_netconsole()
962 free_param_target(nt); in cleanup_netconsole()