Lines Matching refs:drv
34 struct macsec_drv_data *drv;
130 static int init_genl_ctx(struct macsec_drv_data *drv)
132 struct macsec_genl_ctx *ctx = &drv->ctx;
153 ctx->cb_arg.drv = drv;
167 static int try_commit(struct macsec_drv_data *drv)
171 if (!drv->link)
174 if (drv->controlled_port_enabled_set) {
180 rtnl_link_set_name(change, drv->ifname);
182 if (drv->controlled_port_enabled)
187 err = rtnl_link_change(drv->sk, change, change, 0);
193 drv->controlled_port_enabled_set = FALSE;
196 if (drv->protect_frames_set)
197 rtnl_link_macsec_set_protect(drv->link, drv->protect_frames);
199 if (drv->encrypt_set)
200 rtnl_link_macsec_set_encrypt(drv->link, drv->encrypt);
202 if (drv->replay_protect_set) {
203 rtnl_link_macsec_set_replay_protect(drv->link,
204 drv->replay_protect);
205 if (drv->replay_protect)
206 rtnl_link_macsec_set_window(drv->link,
207 drv->replay_window);
210 if (drv->encoding_sa_set)
211 rtnl_link_macsec_set_encoding_sa(drv->link, drv->encoding_sa);
213 err = rtnl_link_add(drv->sk, drv->link, 0);
217 drv->protect_frames_set = FALSE;
218 drv->encrypt_set = FALSE;
219 drv->replay_protect_set = FALSE;
227 struct macsec_drv_data *drv = priv;
229 driver_wired_deinit_common(&drv->common);
230 os_free(drv);
236 struct macsec_drv_data *drv;
238 drv = os_zalloc(sizeof(*drv));
239 if (!drv)
242 if (driver_wired_init_common(&drv->common, ifname, ctx) < 0) {
243 os_free(drv);
247 return drv;
253 struct macsec_drv_data *drv = priv;
258 drv->sk = nl_socket_alloc();
259 if (!drv->sk)
262 err = nl_connect(drv->sk, NETLINK_ROUTE);
270 err = rtnl_link_alloc_cache(drv->sk, AF_UNSPEC, &drv->link_cache);
277 drv->parent_ifi = rtnl_link_name2i(drv->link_cache, drv->common.ifname);
278 if (drv->parent_ifi == 0) {
281 drv->common.ifname);
285 err = init_genl_ctx(drv);
292 nl_cache_free(drv->link_cache);
293 drv->link_cache = NULL;
295 nl_socket_free(drv->sk);
296 drv->sk = NULL;
303 struct macsec_drv_data *drv = priv;
307 if (drv->sk)
308 nl_socket_free(drv->sk);
309 drv->sk = NULL;
311 if (drv->link_cache)
312 nl_cache_free(drv->link_cache);
313 drv->link_cache = NULL;
315 if (drv->ctx.sk)
316 nl_socket_free(drv->ctx.sk);
341 struct macsec_drv_data *drv = priv;
345 drv->protect_frames_set = TRUE;
346 drv->protect_frames = enabled;
348 return try_commit(drv);
361 struct macsec_drv_data *drv = priv;
365 drv->encrypt_set = TRUE;
366 drv->encrypt = enabled;
368 return try_commit(drv);
383 struct macsec_drv_data *drv = priv;
388 drv->replay_protect_set = TRUE;
389 drv->replay_protect = enabled;
391 drv->replay_window = window;
393 return try_commit(drv);
419 struct macsec_drv_data *drv = priv;
423 drv->controlled_port_enabled = enabled;
424 drv->controlled_port_enabled_set = TRUE;
426 return try_commit(drv);
458 if (ret_hdr->nlmsg_type != arg->drv->ctx.macsec_genl_id)
572 static int do_dump(struct macsec_drv_data *drv, u8 txsa, u64 rxsci, u8 rxsa,
575 struct macsec_genl_ctx *ctx = &drv->ctx;
579 ctx->cb_arg.ifindex = drv->ifi;
621 struct macsec_drv_data *drv = priv;
626 err = do_dump(drv, 0xff, mka_sci_u64(&sa->sc->sci), sa->an,
643 struct macsec_drv_data *drv = priv;
648 err = do_dump(drv, sa->an, UNUSED_SCI, 0xff, &sa->next_pn);
663 struct macsec_drv_data *drv = priv;
664 struct macsec_genl_ctx *ctx = &drv->ctx;
671 msg = msg_prepare(MACSEC_CMD_UPD_TXSA, ctx, drv->ifi);
715 struct macsec_drv_data *drv = priv;
716 struct macsec_genl_ctx *ctx = &drv->ctx;
723 msg = msg_prepare(MACSEC_CMD_ADD_RXSC, ctx, drv->ifi);
751 struct macsec_drv_data *drv = priv;
752 struct macsec_genl_ctx *ctx = &drv->ctx;
759 msg = msg_prepare(MACSEC_CMD_DEL_RXSC, ctx, drv->ifi);
787 struct macsec_drv_data *drv = priv;
788 struct macsec_genl_ctx *ctx = &drv->ctx;
796 msg = msg_prepare(MACSEC_CMD_ADD_RXSA, ctx, drv->ifi);
837 struct macsec_drv_data *drv = priv;
838 struct macsec_genl_ctx *ctx = &drv->ctx;
846 msg = msg_prepare(MACSEC_CMD_DEL_RXSA, ctx, drv->ifi);
917 struct macsec_drv_data *drv = priv;
918 struct macsec_genl_ctx *ctx = &drv->ctx;
923 return set_active_rx_sa(ctx, drv->ifi, mka_sci_u64(&sa->sc->sci),
936 struct macsec_drv_data *drv = priv;
937 struct macsec_genl_ctx *ctx = &drv->ctx;
942 return set_active_rx_sa(ctx, drv->ifi, mka_sci_u64(&sa->sc->sci),
977 struct macsec_drv_data *drv = priv;
991 rtnl_link_set_link(link, drv->parent_ifi);
996 drv->created_link = TRUE;
998 err = rtnl_link_add(drv->sk, link, NLM_F_CREATE);
1002 drv->created_link = FALSE;
1012 nl_cache_refill(drv->sk, drv->link_cache);
1013 link = lookup_sc(drv->link_cache, drv->parent_ifi, sci);
1019 drv->ifi = rtnl_link_get_ifindex(link);
1021 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
1024 drv->link = rtnl_link_macsec_alloc();
1025 if (!drv->link) {
1030 rtnl_link_set_name(drv->link, drv->ifname);
1034 return try_commit(drv);
1046 struct macsec_drv_data *drv = priv;
1051 if (!drv->created_link) {
1052 rtnl_link_put(drv->link);
1053 drv->link = NULL;
1059 err = rtnl_link_delete(drv->sk, drv->link);
1062 rtnl_link_put(drv->link);
1063 drv->link = NULL;
1077 struct macsec_drv_data *drv = priv;
1078 struct macsec_genl_ctx *ctx = &drv->ctx;
1085 msg = msg_prepare(MACSEC_CMD_ADD_TXSA, ctx, drv->ifi);
1123 struct macsec_drv_data *drv = priv;
1124 struct macsec_genl_ctx *ctx = &drv->ctx;
1131 msg = msg_prepare(MACSEC_CMD_DEL_TXSA, ctx, drv->ifi);
1197 struct macsec_drv_data *drv = priv;
1198 struct macsec_genl_ctx *ctx = &drv->ctx;
1203 ret = set_active_tx_sa(ctx, drv->ifi, sa->an, TRUE);
1209 drv->encoding_sa_set = TRUE;
1210 drv->encoding_sa = sa->an;
1212 return try_commit(drv);
1224 struct macsec_drv_data *drv = priv;
1225 struct macsec_genl_ctx *ctx = &drv->ctx;
1229 return set_active_tx_sa(ctx, drv->ifi, sa->an, FALSE);