Lines Matching refs:nt

129 static void netconsole_target_get(struct netconsole_target *nt)  in netconsole_target_get()  argument
131 if (config_item_name(&nt->item)) in netconsole_target_get()
132 config_item_get(&nt->item); in netconsole_target_get()
135 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
137 if (config_item_name(&nt->item)) in netconsole_target_put()
138 config_item_put(&nt->item); in netconsole_target_put()
156 static void netconsole_target_get(struct netconsole_target *nt) in netconsole_target_get() argument
160 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
170 struct netconsole_target *nt; in alloc_param_target() local
176 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in alloc_param_target()
177 if (!nt) in alloc_param_target()
180 nt->np.name = "netconsole"; in alloc_param_target()
181 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); in alloc_param_target()
182 nt->np.local_port = 6665; in alloc_param_target()
183 nt->np.remote_port = 6666; in alloc_param_target()
184 eth_broadcast_addr(nt->np.remote_mac); in alloc_param_target()
187 nt->extended = true; in alloc_param_target()
192 err = netpoll_parse_options(&nt->np, target_config); in alloc_param_target()
196 err = netpoll_setup(&nt->np); in alloc_param_target()
200 nt->enabled = true; in alloc_param_target()
202 return nt; in alloc_param_target()
205 kfree(nt); in alloc_param_target()
210 static void free_param_target(struct netconsole_target *nt) in free_param_target() argument
212 netpoll_cleanup(&nt->np); in free_param_target()
213 kfree(nt); in free_param_target()
274 struct netconsole_target *nt = to_target(item); in local_ip_show() local
276 if (nt->np.ipv6) in local_ip_show()
277 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); in local_ip_show()
279 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); in local_ip_show()
284 struct netconsole_target *nt = to_target(item); in remote_ip_show() local
286 if (nt->np.ipv6) in remote_ip_show()
287 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); in remote_ip_show()
289 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); in remote_ip_show()
315 struct netconsole_target *nt = to_target(item); in enabled_store() local
328 if ((bool)enabled == nt->enabled) { in enabled_store()
330 nt->enabled ? "started" : "stopped"); in enabled_store()
335 if (nt->extended && !(netconsole_ext.flags & CON_ENABLED)) { in enabled_store()
344 netpoll_print_options(&nt->np); in enabled_store()
346 err = netpoll_setup(&nt->np); in enabled_store()
357 nt->enabled = false; in enabled_store()
359 netpoll_cleanup(&nt->np); in enabled_store()
362 nt->enabled = enabled; in enabled_store()
374 struct netconsole_target *nt = to_target(item); in extended_store() local
379 if (nt->enabled) { in extended_store()
381 config_item_name(&nt->item)); in extended_store()
394 nt->extended = extended; in extended_store()
406 struct netconsole_target *nt = to_target(item); in dev_name_store() local
410 if (nt->enabled) { in dev_name_store()
412 config_item_name(&nt->item)); in dev_name_store()
417 strlcpy(nt->np.dev_name, buf, IFNAMSIZ); in dev_name_store()
420 len = strnlen(nt->np.dev_name, IFNAMSIZ); in dev_name_store()
421 if (nt->np.dev_name[len - 1] == '\n') in dev_name_store()
422 nt->np.dev_name[len - 1] = '\0'; in dev_name_store()
431 struct netconsole_target *nt = to_target(item); in local_port_store() local
435 if (nt->enabled) { in local_port_store()
437 config_item_name(&nt->item)); in local_port_store()
441 rv = kstrtou16(buf, 10, &nt->np.local_port); in local_port_store()
454 struct netconsole_target *nt = to_target(item); in remote_port_store() local
458 if (nt->enabled) { in remote_port_store()
460 config_item_name(&nt->item)); in remote_port_store()
464 rv = kstrtou16(buf, 10, &nt->np.remote_port); in remote_port_store()
477 struct netconsole_target *nt = to_target(item); in local_ip_store() local
480 if (nt->enabled) { in local_ip_store()
482 config_item_name(&nt->item)); in local_ip_store()
488 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { in local_ip_store()
493 nt->np.ipv6 = true; in local_ip_store()
497 if (!nt->np.ipv6) { in local_ip_store()
498 nt->np.local_ip.ip = in_aton(buf); in local_ip_store()
513 struct netconsole_target *nt = to_target(item); in remote_ip_store() local
516 if (nt->enabled) { in remote_ip_store()
518 config_item_name(&nt->item)); in remote_ip_store()
524 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { in remote_ip_store()
529 nt->np.ipv6 = true; in remote_ip_store()
533 if (!nt->np.ipv6) { in remote_ip_store()
534 nt->np.remote_ip.ip = in_aton(buf); in remote_ip_store()
549 struct netconsole_target *nt = to_target(item); in remote_mac_store() local
553 if (nt->enabled) { in remote_mac_store()
555 config_item_name(&nt->item)); in remote_mac_store()
563 memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); in remote_mac_store()
622 struct netconsole_target *nt; in make_netconsole_target() local
628 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in make_netconsole_target()
629 if (!nt) in make_netconsole_target()
632 nt->np.name = "netconsole"; in make_netconsole_target()
633 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); in make_netconsole_target()
634 nt->np.local_port = 6665; in make_netconsole_target()
635 nt->np.remote_port = 6666; in make_netconsole_target()
636 eth_broadcast_addr(nt->np.remote_mac); in make_netconsole_target()
639 config_item_init_type_name(&nt->item, name, &netconsole_target_type); in make_netconsole_target()
643 list_add(&nt->list, &target_list); in make_netconsole_target()
646 return &nt->item; in make_netconsole_target()
653 struct netconsole_target *nt = to_target(item); in drop_netconsole_target() local
656 list_del(&nt->list); in drop_netconsole_target()
663 if (nt->enabled) in drop_netconsole_target()
664 netpoll_cleanup(&nt->np); in drop_netconsole_target()
666 config_item_put(&nt->item); in drop_netconsole_target()
696 struct netconsole_target *nt; in netconsole_netdev_event() local
706 list_for_each_entry(nt, &target_list, list) { in netconsole_netdev_event()
707 netconsole_target_get(nt); in netconsole_netdev_event()
708 if (nt->np.dev == dev) { in netconsole_netdev_event()
711 strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); in netconsole_netdev_event()
721 __netpoll_cleanup(&nt->np); in netconsole_netdev_event()
724 dev_put(nt->np.dev); in netconsole_netdev_event()
725 nt->np.dev = NULL; in netconsole_netdev_event()
726 nt->enabled = false; in netconsole_netdev_event()
728 netconsole_target_put(nt); in netconsole_netdev_event()
732 netconsole_target_put(nt); in netconsole_netdev_event()
770 static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg, in send_ext_msg_udp() argument
779 netpoll_send_udp(&nt->np, msg, msg_len); in send_ext_msg_udp()
814 netpoll_send_udp(&nt->np, buf, this_header + this_chunk); in send_ext_msg_udp()
823 struct netconsole_target *nt; in write_ext_msg() local
830 list_for_each_entry(nt, &target_list, list) in write_ext_msg()
831 if (nt->extended && nt->enabled && netif_running(nt->np.dev)) in write_ext_msg()
832 send_ext_msg_udp(nt, msg, len); in write_ext_msg()
840 struct netconsole_target *nt; in write_msg() local
850 list_for_each_entry(nt, &target_list, list) { in write_msg()
851 if (!nt->extended && nt->enabled && netif_running(nt->np.dev)) { in write_msg()
861 netpoll_send_udp(&nt->np, tmp, frag); in write_msg()
885 struct netconsole_target *nt, *tmp; in init_netconsole() local
892 nt = alloc_param_target(target_config); in init_netconsole()
893 if (IS_ERR(nt)) { in init_netconsole()
894 err = PTR_ERR(nt); in init_netconsole()
898 if (nt->extended) in init_netconsole()
905 list_add(&nt->list, &target_list); in init_netconsole()
936 list_for_each_entry_safe(nt, tmp, &target_list, list) { in init_netconsole()
937 list_del(&nt->list); in init_netconsole()
938 free_param_target(nt); in init_netconsole()
946 struct netconsole_target *nt, *tmp; in cleanup_netconsole() local
961 list_for_each_entry_safe(nt, tmp, &target_list, list) { in cleanup_netconsole()
962 list_del(&nt->list); in cleanup_netconsole()
963 free_param_target(nt); in cleanup_netconsole()