Lines Matching defs:ctx

94 static void link_configs_free(link_config_ctx *ctx) {
97 if (!ctx)
100 LIST_FOREACH_SAFE(links, link, link_next, ctx->links)
104 void link_config_ctx_free(link_config_ctx *ctx) {
105 if (!ctx)
108 safe_close(ctx->ethtool_fd);
110 sd_netlink_unref(ctx->rtnl);
112 link_configs_free(ctx);
114 free(ctx);
122 _cleanup_(link_config_ctx_freep) link_config_ctx *ctx = NULL;
127 ctx = new0(link_config_ctx, 1);
128 if (!ctx)
131 LIST_HEAD_INIT(ctx->links);
133 ctx->ethtool_fd = -1;
135 ctx->enable_name_policy = true;
137 *ret = ctx;
138 ctx = NULL;
143 static int load_link(link_config_ctx *ctx, const char *filename) {
148 assert(ctx);
186 LIST_PREPEND(links, ctx->links, link);
211 int link_config_load(link_config_ctx *ctx) {
216 link_configs_free(ctx);
219 ctx->enable_name_policy = false;
224 paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, true);
231 r = load_link(ctx, *f);
239 bool link_config_should_reload(link_config_ctx *ctx) {
240 return paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, false);
243 int link_config_get(link_config_ctx *ctx, struct udev_device *device,
247 assert(ctx);
251 LIST_FOREACH(links, link, ctx->links) {
372 int link_config_apply(link_config_ctx *ctx, link_config *config,
381 assert(ctx);
390 r = ethtool_set_speed(&ctx->ethtool_fd, old_name, config->speed / 1024, config->duplex);
396 r = ethtool_set_wol(&ctx->ethtool_fd, old_name, config->wol);
407 if (ctx->enable_name_policy && config->name_policy) {
472 r = rtnl_set_link_properties(&ctx->rtnl, ifindex, config->alias, mac, config->mtu);
481 int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret) {
490 r = ethtool_get_driver(&ctx->ethtool_fd, name, &driver);