Lines Matching refs:netdev
95 static int netdev_l2tp_create_message_tunnel(NetDev *netdev, union in_addr_union *local_address, sd… in netdev_l2tp_create_message_tunnel() argument
101 assert(netdev); in netdev_l2tp_create_message_tunnel()
103 assert_se(t = L2TP(netdev)); in netdev_l2tp_create_message_tunnel()
105 r = sd_genl_message_new(netdev->manager->genl, L2TP_GENL_NAME, L2TP_CMD_TUNNEL_CREATE, &m); in netdev_l2tp_create_message_tunnel()
186 static int netdev_l2tp_create_message_session(NetDev *netdev, L2tpSession *session, sd_netlink_mess… in netdev_l2tp_create_message_session() argument
192 assert(netdev); in netdev_l2tp_create_message_session()
196 r = sd_genl_message_new(netdev->manager->genl, L2TP_GENL_NAME, L2TP_CMD_SESSION_CREATE, &m); in netdev_l2tp_create_message_session()
280 static int l2tp_get_local_address(NetDev *netdev, union in_addr_union *ret) { in l2tp_get_local_address() argument
286 assert(netdev); in l2tp_get_local_address()
287 assert(netdev->manager); in l2tp_get_local_address()
288 assert_se(t = L2TP(netdev)); in l2tp_get_local_address()
291 r = link_get_by_name(netdev->manager, t->local_ifname, &link); in l2tp_get_local_address()
299 if (netdev->manager->manage_foreign_routes) { in l2tp_get_local_address()
304 … r = manager_address_is_reachable(netdev->manager, t->family, &t->remote, &t->local, &a); in l2tp_get_local_address()
316 … r = manager_get_address(netdev->manager, t->family, &t->local, 0, &a); in l2tp_get_local_address()
348 HASHMAP_FOREACH(link, netdev->manager->links_by_index) { in l2tp_get_local_address()
367 NetDev *netdev; in l2tp_create_session_handler() local
373 netdev = NETDEV(session->tunnel); in l2tp_create_session_handler()
377 … log_netdev_info(netdev, "L2TP session %s exists, using existing without changing its parameters", in l2tp_create_session_handler()
380 … log_netdev_warning_errno(netdev, r, "L2TP session %s could not be created: %m", session->name); in l2tp_create_session_handler()
384 log_netdev_debug(netdev, "L2TP session %s created", session->name); in l2tp_create_session_handler()
388 static int l2tp_create_session(NetDev *netdev, L2tpSession *session) { in l2tp_create_session() argument
392 r = netdev_l2tp_create_message_session(netdev, session, &n); in l2tp_create_session()
394 return log_netdev_error_errno(netdev, r, "Failed to create netlink message: %m"); in l2tp_create_session()
396 r = netlink_call_async(netdev->manager->genl, NULL, n, l2tp_create_session_handler, in l2tp_create_session()
399 … return log_netdev_error_errno(netdev, r, "Failed to create L2TP session %s: %m", session->name); in l2tp_create_session()
401 netdev_ref(netdev); in l2tp_create_session()
405 static int l2tp_create_tunnel_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) { in l2tp_create_tunnel_handler() argument
410 assert(netdev); in l2tp_create_tunnel_handler()
411 assert(netdev->state != _NETDEV_STATE_INVALID); in l2tp_create_tunnel_handler()
413 t = L2TP(netdev); in l2tp_create_tunnel_handler()
419 … log_netdev_info(netdev, "netdev exists, using existing without changing its parameters"); in l2tp_create_tunnel_handler()
421 log_netdev_warning_errno(netdev, r, "netdev could not be created: %m"); in l2tp_create_tunnel_handler()
422 netdev_enter_failed(netdev); in l2tp_create_tunnel_handler()
427 log_netdev_debug(netdev, "L2TP tunnel is created"); in l2tp_create_tunnel_handler()
430 (void) l2tp_create_session(netdev, session); in l2tp_create_tunnel_handler()
435 static int l2tp_create_tunnel(NetDev *netdev) { in l2tp_create_tunnel() argument
441 assert(netdev); in l2tp_create_tunnel()
442 assert_se(t = L2TP(netdev)); in l2tp_create_tunnel()
444 r = l2tp_get_local_address(netdev, &local_address); in l2tp_create_tunnel()
446 return log_netdev_error_errno(netdev, r, "Could not find local address."); in l2tp_create_tunnel()
452 log_netdev_debug(netdev, "Local address %s acquired.", strna(str)); in l2tp_create_tunnel()
455 r = netdev_l2tp_create_message_tunnel(netdev, &local_address, &m); in l2tp_create_tunnel()
457 return log_netdev_error_errno(netdev, r, "Failed to create netlink message: %m"); in l2tp_create_tunnel()
459 r = netlink_call_async(netdev->manager->genl, NULL, m, l2tp_create_tunnel_handler, in l2tp_create_tunnel()
460 netdev_destroy_callback, netdev); in l2tp_create_tunnel()
462 return log_netdev_error_errno(netdev, r, "Failed to create L2TP tunnel: %m"); in l2tp_create_tunnel()
464 netdev_ref(netdev); in l2tp_create_tunnel()
469 static int netdev_l2tp_is_ready_to_create(NetDev *netdev, Link *link) { in netdev_l2tp_is_ready_to_create() argument
470 return l2tp_get_local_address(netdev, NULL) >= 0; in netdev_l2tp_is_ready_to_create()
791 static void l2tp_tunnel_init(NetDev *netdev) { in l2tp_tunnel_init() argument
794 assert(netdev); in l2tp_tunnel_init()
796 t = L2TP(netdev); in l2tp_tunnel_init()
806 NetDev *netdev; in l2tp_session_verify() local
811 netdev = NETDEV(session->tunnel); in l2tp_session_verify()
817 return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL), in l2tp_session_verify()
823 return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL), in l2tp_session_verify()
831 static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) { in netdev_l2tp_tunnel_verify() argument
835 assert(netdev); in netdev_l2tp_tunnel_verify()
838 t = L2TP(netdev); in netdev_l2tp_tunnel_verify()
843 return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL), in netdev_l2tp_tunnel_verify()
848 return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL), in netdev_l2tp_tunnel_verify()
853 return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL), in netdev_l2tp_tunnel_verify()
864 static void l2tp_tunnel_done(NetDev *netdev) { in l2tp_tunnel_done() argument
867 assert(netdev); in l2tp_tunnel_done()
869 t = L2TP(netdev); in l2tp_tunnel_done()