Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: fib_notifier: propagate extack down to the notifier block callback

Since errors are propagated all the way up to the caller, propagate
possible extack of the caller all the way down to the notifier block
callback.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
b7a59557 3f9e5c11

+105 -61
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c
··· 309 309 310 310 mp->fib_nb.notifier_call = mlx5_lag_fib_event; 311 311 err = register_fib_notifier(&init_net, &mp->fib_nb, 312 - mlx5_lag_fib_event_flush); 312 + mlx5_lag_fib_event_flush, NULL); 313 313 if (err) 314 314 mp->fib_nb.notifier_call = NULL; 315 315
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 8135 8135 8136 8136 mlxsw_sp->router->fib_nb.notifier_call = mlxsw_sp_router_fib_event; 8137 8137 err = register_fib_notifier(&init_net, &mlxsw_sp->router->fib_nb, 8138 - mlxsw_sp_router_fib_dump_flush); 8138 + mlxsw_sp_router_fib_dump_flush, NULL); 8139 8139 if (err) 8140 8140 goto err_register_fib_notifier; 8141 8141
+1 -1
drivers/net/ethernet/rocker/rocker_main.c
··· 2991 2991 * the device, so no need to pass a callback. 2992 2992 */ 2993 2993 rocker->fib_nb.notifier_call = rocker_router_fib_event; 2994 - err = register_fib_notifier(&init_net, &rocker->fib_nb, NULL); 2994 + err = register_fib_notifier(&init_net, &rocker->fib_nb, NULL, NULL); 2995 2995 if (err) 2996 2996 goto err_register_fib_notifier; 2997 2997
+1 -1
drivers/net/netdevsim/fib.c
··· 256 256 257 257 data->fib_nb.notifier_call = nsim_fib_event_nb; 258 258 err = register_fib_notifier(&init_net, &data->fib_nb, 259 - nsim_fib_dump_inconsistent); 259 + nsim_fib_dump_inconsistent, NULL); 260 260 if (err) { 261 261 pr_err("Failed to register fib notifier\n"); 262 262 goto err_out;
+12 -6
include/linux/mroute_base.h
··· 50 50 unsigned short family, 51 51 enum fib_event_type event_type, 52 52 struct vif_device *vif, 53 - unsigned short vif_index, u32 tb_id) 53 + unsigned short vif_index, u32 tb_id, 54 + struct netlink_ext_ack *extack) 54 55 { 55 56 struct vif_entry_notifier_info info = { 56 57 .info = { 57 58 .family = family, 59 + .extack = extack, 58 60 }, 59 61 .dev = vif->dev, 60 62 .vif_index = vif_index, ··· 174 172 static inline int mr_call_mfc_notifier(struct notifier_block *nb, 175 173 unsigned short family, 176 174 enum fib_event_type event_type, 177 - struct mr_mfc *mfc, u32 tb_id) 175 + struct mr_mfc *mfc, u32 tb_id, 176 + struct netlink_ext_ack *extack) 178 177 { 179 178 struct mfc_entry_notifier_info info = { 180 179 .info = { 181 180 .family = family, 181 + .extack = extack, 182 182 }, 183 183 .mfc = mfc, 184 184 .tb_id = tb_id ··· 299 295 300 296 int mr_dump(struct net *net, struct notifier_block *nb, unsigned short family, 301 297 int (*rules_dump)(struct net *net, 302 - struct notifier_block *nb), 298 + struct notifier_block *nb, 299 + struct netlink_ext_ack *extack), 303 300 struct mr_table *(*mr_iter)(struct net *net, 304 301 struct mr_table *mrt), 305 - rwlock_t *mrt_lock); 302 + rwlock_t *mrt_lock, struct netlink_ext_ack *extack); 306 303 #else 307 304 static inline void vif_device_init(struct vif_device *v, 308 305 struct net_device *dev, ··· 354 349 static inline int mr_dump(struct net *net, struct notifier_block *nb, 355 350 unsigned short family, 356 351 int (*rules_dump)(struct net *net, 357 - struct notifier_block *nb), 352 + struct notifier_block *nb, 353 + struct netlink_ext_ack *extack), 358 354 struct mr_table *(*mr_iter)(struct net *net, 359 355 struct mr_table *mrt), 360 - rwlock_t *mrt_lock) 356 + rwlock_t *mrt_lock, struct netlink_ext_ack *extack) 361 357 { 362 358 return -EINVAL; 363 359 }
+4 -2
include/net/fib_notifier.h
··· 29 29 int family; 30 30 struct list_head list; 31 31 unsigned int (*fib_seq_read)(struct net *net); 32 - int (*fib_dump)(struct net *net, struct notifier_block *nb); 32 + int (*fib_dump)(struct net *net, struct notifier_block *nb, 33 + struct netlink_ext_ack *extack); 33 34 struct module *owner; 34 35 struct rcu_head rcu; 35 36 }; ··· 41 40 int call_fib_notifiers(struct net *net, enum fib_event_type event_type, 42 41 struct fib_notifier_info *info); 43 42 int register_fib_notifier(struct net *net, struct notifier_block *nb, 44 - void (*cb)(struct notifier_block *nb)); 43 + void (*cb)(struct notifier_block *nb), 44 + struct netlink_ext_ack *extack); 45 45 int unregister_fib_notifier(struct net *net, struct notifier_block *nb); 46 46 struct fib_notifier_ops * 47 47 fib_notifier_ops_register(const struct fib_notifier_ops *tmpl, struct net *net);
+2 -1
include/net/fib_rules.h
··· 194 194 int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table, 195 195 u32 flags); 196 196 bool fib_rule_matchall(const struct fib_rule *rule); 197 - int fib_rules_dump(struct net *net, struct notifier_block *nb, int family); 197 + int fib_rules_dump(struct net *net, struct notifier_block *nb, int family, 198 + struct netlink_ext_ack *extack); 198 199 unsigned int fib_rules_seq_read(struct net *net, int family); 199 200 200 201 int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
+6 -3
include/net/ip6_fib.h
··· 488 488 void __net_exit fib6_notifier_exit(struct net *net); 489 489 490 490 unsigned int fib6_tables_seq_read(struct net *net); 491 - int fib6_tables_dump(struct net *net, struct notifier_block *nb); 491 + int fib6_tables_dump(struct net *net, struct notifier_block *nb, 492 + struct netlink_ext_ack *extack); 492 493 493 494 void fib6_update_sernum(struct net *net, struct fib6_info *rt); 494 495 void fib6_update_sernum_upto_root(struct net *net, struct fib6_info *rt); ··· 505 504 int fib6_rules_init(void); 506 505 void fib6_rules_cleanup(void); 507 506 bool fib6_rule_default(const struct fib_rule *rule); 508 - int fib6_rules_dump(struct net *net, struct notifier_block *nb); 507 + int fib6_rules_dump(struct net *net, struct notifier_block *nb, 508 + struct netlink_ext_ack *extack); 509 509 unsigned int fib6_rules_seq_read(struct net *net); 510 510 511 511 static inline bool fib6_rules_early_flow_dissect(struct net *net, ··· 539 537 { 540 538 return true; 541 539 } 542 - static inline int fib6_rules_dump(struct net *net, struct notifier_block *nb) 540 + static inline int fib6_rules_dump(struct net *net, struct notifier_block *nb, 541 + struct netlink_ext_ack *extack) 543 542 { 544 543 return 0; 545 544 }
+6 -3
include/net/ip_fib.h
··· 229 229 void __net_exit fib4_notifier_exit(struct net *net); 230 230 231 231 void fib_info_notify_update(struct net *net, struct nl_info *info); 232 - int fib_notify(struct net *net, struct notifier_block *nb); 232 + int fib_notify(struct net *net, struct notifier_block *nb, 233 + struct netlink_ext_ack *extack); 233 234 234 235 struct fib_table { 235 236 struct hlist_node tb_hlist; ··· 316 315 return true; 317 316 } 318 317 319 - static inline int fib4_rules_dump(struct net *net, struct notifier_block *nb) 318 + static inline int fib4_rules_dump(struct net *net, struct notifier_block *nb, 319 + struct netlink_ext_ack *extack) 320 320 { 321 321 return 0; 322 322 } ··· 379 377 } 380 378 381 379 bool fib4_rule_default(const struct fib_rule *rule); 382 - int fib4_rules_dump(struct net *net, struct notifier_block *nb); 380 + int fib4_rules_dump(struct net *net, struct notifier_block *nb, 381 + struct netlink_ext_ack *extack); 383 382 unsigned int fib4_rules_seq_read(struct net *net); 384 383 385 384 static inline bool fib4_rules_early_flow_dissect(struct net *net,
+6 -4
net/core/fib_notifier.c
··· 57 57 return fib_seq; 58 58 } 59 59 60 - static int fib_net_dump(struct net *net, struct notifier_block *nb) 60 + static int fib_net_dump(struct net *net, struct notifier_block *nb, 61 + struct netlink_ext_ack *extack) 61 62 { 62 63 struct fib_notifier_net *fn_net = net_generic(net, fib_notifier_net_id); 63 64 struct fib_notifier_ops *ops; ··· 68 67 list_for_each_entry_rcu(ops, &fn_net->fib_notifier_ops, list) { 69 68 if (!try_module_get(ops->owner)) 70 69 continue; 71 - err = ops->fib_dump(net, nb); 70 + err = ops->fib_dump(net, nb, extack); 72 71 module_put(ops->owner); 73 72 if (err) 74 73 goto unlock; ··· 97 96 98 97 #define FIB_DUMP_MAX_RETRIES 5 99 98 int register_fib_notifier(struct net *net, struct notifier_block *nb, 100 - void (*cb)(struct notifier_block *nb)) 99 + void (*cb)(struct notifier_block *nb), 100 + struct netlink_ext_ack *extack) 101 101 { 102 102 int retries = 0; 103 103 int err; ··· 106 104 do { 107 105 unsigned int fib_seq = fib_seq_sum(net); 108 106 109 - err = fib_net_dump(net, nb); 107 + err = fib_net_dump(net, nb, extack); 110 108 if (err) 111 109 return err; 112 110
+6 -3
net/core/fib_rules.c
··· 323 323 324 324 static int call_fib_rule_notifier(struct notifier_block *nb, 325 325 enum fib_event_type event_type, 326 - struct fib_rule *rule, int family) 326 + struct fib_rule *rule, int family, 327 + struct netlink_ext_ack *extack) 327 328 { 328 329 struct fib_rule_notifier_info info = { 329 330 .info.family = family, 331 + .info.extack = extack, 330 332 .rule = rule, 331 333 }; 332 334 ··· 352 350 } 353 351 354 352 /* Called with rcu_read_lock() */ 355 - int fib_rules_dump(struct net *net, struct notifier_block *nb, int family) 353 + int fib_rules_dump(struct net *net, struct notifier_block *nb, int family, 354 + struct netlink_ext_ack *extack) 356 355 { 357 356 struct fib_rules_ops *ops; 358 357 struct fib_rule *rule; ··· 364 361 return -EAFNOSUPPORT; 365 362 list_for_each_entry_rcu(rule, &ops->rules_list, list) { 366 363 err = call_fib_rule_notifier(nb, FIB_EVENT_RULE_ADD, 367 - rule, family); 364 + rule, family, extack); 368 365 if (err) 369 366 break; 370 367 }
+4 -3
net/ipv4/fib_notifier.c
··· 34 34 return net->ipv4.fib_seq + fib4_rules_seq_read(net); 35 35 } 36 36 37 - static int fib4_dump(struct net *net, struct notifier_block *nb) 37 + static int fib4_dump(struct net *net, struct notifier_block *nb, 38 + struct netlink_ext_ack *extack) 38 39 { 39 40 int err; 40 41 41 - err = fib4_rules_dump(net, nb); 42 + err = fib4_rules_dump(net, nb, extack); 42 43 if (err) 43 44 return err; 44 45 45 - return fib_notify(net, nb); 46 + return fib_notify(net, nb, extack); 46 47 } 47 48 48 49 static const struct fib_notifier_ops fib4_notifier_ops_template = {
+3 -2
net/ipv4/fib_rules.c
··· 65 65 } 66 66 EXPORT_SYMBOL_GPL(fib4_rule_default); 67 67 68 - int fib4_rules_dump(struct net *net, struct notifier_block *nb) 68 + int fib4_rules_dump(struct net *net, struct notifier_block *nb, 69 + struct netlink_ext_ack *extack) 69 70 { 70 - return fib_rules_dump(net, nb, AF_INET); 71 + return fib_rules_dump(net, nb, AF_INET, extack); 71 72 } 72 73 73 74 unsigned int fib4_rules_seq_read(struct net *net)
+13 -7
net/ipv4/fib_trie.c
··· 76 76 77 77 static int call_fib_entry_notifier(struct notifier_block *nb, 78 78 enum fib_event_type event_type, u32 dst, 79 - int dst_len, struct fib_alias *fa) 79 + int dst_len, struct fib_alias *fa, 80 + struct netlink_ext_ack *extack) 80 81 { 81 82 struct fib_entry_notifier_info info = { 83 + .info.extack = extack, 82 84 .dst = dst, 83 85 .dst_len = dst_len, 84 86 .fi = fa->fa_info, ··· 2018 2016 } 2019 2017 2020 2018 static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb, 2021 - struct notifier_block *nb) 2019 + struct notifier_block *nb, 2020 + struct netlink_ext_ack *extack) 2022 2021 { 2023 2022 struct fib_alias *fa; 2024 2023 int err; ··· 2037 2034 continue; 2038 2035 2039 2036 err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_ADD, l->key, 2040 - KEYLENGTH - fa->fa_slen, fa); 2037 + KEYLENGTH - fa->fa_slen, 2038 + fa, extack); 2041 2039 if (err) 2042 2040 return err; 2043 2041 } 2044 2042 return 0; 2045 2043 } 2046 2044 2047 - static int fib_table_notify(struct fib_table *tb, struct notifier_block *nb) 2045 + static int fib_table_notify(struct fib_table *tb, struct notifier_block *nb, 2046 + struct netlink_ext_ack *extack) 2048 2047 { 2049 2048 struct trie *t = (struct trie *)tb->tb_data; 2050 2049 struct key_vector *l, *tp = t->kv; ··· 2054 2049 int err; 2055 2050 2056 2051 while ((l = leaf_walk_rcu(&tp, key)) != NULL) { 2057 - err = fib_leaf_notify(l, tb, nb); 2052 + err = fib_leaf_notify(l, tb, nb, extack); 2058 2053 if (err) 2059 2054 return err; 2060 2055 ··· 2066 2061 return 0; 2067 2062 } 2068 2063 2069 - int fib_notify(struct net *net, struct notifier_block *nb) 2064 + int fib_notify(struct net *net, struct notifier_block *nb, 2065 + struct netlink_ext_ack *extack) 2070 2066 { 2071 2067 unsigned int h; 2072 2068 int err; ··· 2077 2071 struct fib_table *tb; 2078 2072 2079 2073 hlist_for_each_entry_rcu(tb, head, tb_hlist) { 2080 - err = fib_table_notify(tb, nb); 2074 + err = fib_table_notify(tb, nb, extack); 2081 2075 if (err) 2082 2076 return err; 2083 2077 }
+8 -5
net/ipv4/ipmr.c
··· 278 278 rtnl_unlock(); 279 279 } 280 280 281 - static int ipmr_rules_dump(struct net *net, struct notifier_block *nb) 281 + static int ipmr_rules_dump(struct net *net, struct notifier_block *nb, 282 + struct netlink_ext_ack *extack) 282 283 { 283 - return fib_rules_dump(net, nb, RTNL_FAMILY_IPMR); 284 + return fib_rules_dump(net, nb, RTNL_FAMILY_IPMR, extack); 284 285 } 285 286 286 287 static unsigned int ipmr_rules_seq_read(struct net *net) ··· 337 336 rtnl_unlock(); 338 337 } 339 338 340 - static int ipmr_rules_dump(struct net *net, struct notifier_block *nb) 339 + static int ipmr_rules_dump(struct net *net, struct notifier_block *nb, 340 + struct netlink_ext_ack *extack) 341 341 { 342 342 return 0; 343 343 } ··· 3042 3040 return net->ipv4.ipmr_seq + ipmr_rules_seq_read(net); 3043 3041 } 3044 3042 3045 - static int ipmr_dump(struct net *net, struct notifier_block *nb) 3043 + static int ipmr_dump(struct net *net, struct notifier_block *nb, 3044 + struct netlink_ext_ack *extack) 3046 3045 { 3047 3046 return mr_dump(net, nb, RTNL_FAMILY_IPMR, ipmr_rules_dump, 3048 - ipmr_mr_table_iter, &mrt_lock); 3047 + ipmr_mr_table_iter, &mrt_lock, extack); 3049 3048 } 3050 3049 3051 3050 static const struct fib_notifier_ops ipmr_notifier_ops_template = {
+7 -5
net/ipv4/ipmr_base.c
··· 386 386 387 387 int mr_dump(struct net *net, struct notifier_block *nb, unsigned short family, 388 388 int (*rules_dump)(struct net *net, 389 - struct notifier_block *nb), 389 + struct notifier_block *nb, 390 + struct netlink_ext_ack *extack), 390 391 struct mr_table *(*mr_iter)(struct net *net, 391 392 struct mr_table *mrt), 392 - rwlock_t *mrt_lock) 393 + rwlock_t *mrt_lock, 394 + struct netlink_ext_ack *extack) 393 395 { 394 396 struct mr_table *mrt; 395 397 int err; 396 398 397 - err = rules_dump(net, nb); 399 + err = rules_dump(net, nb, extack); 398 400 if (err) 399 401 return err; 400 402 ··· 413 411 414 412 err = mr_call_vif_notifier(nb, family, 415 413 FIB_EVENT_VIF_ADD, 416 - v, vifi, mrt->id); 414 + v, vifi, mrt->id, extack); 417 415 if (err) 418 416 break; 419 417 } ··· 426 424 list_for_each_entry_rcu(mfc, &mrt->mfc_cache_list, list) { 427 425 err = mr_call_mfc_notifier(nb, family, 428 426 FIB_EVENT_ENTRY_ADD, 429 - mfc, mrt->id); 427 + mfc, mrt->id, extack); 430 428 if (err) 431 429 return err; 432 430 }
+4 -3
net/ipv6/fib6_notifier.c
··· 27 27 return fib6_tables_seq_read(net) + fib6_rules_seq_read(net); 28 28 } 29 29 30 - static int fib6_dump(struct net *net, struct notifier_block *nb) 30 + static int fib6_dump(struct net *net, struct notifier_block *nb, 31 + struct netlink_ext_ack *extack) 31 32 { 32 33 int err; 33 34 34 - err = fib6_rules_dump(net, nb); 35 + err = fib6_rules_dump(net, nb, extack); 35 36 if (err) 36 37 return err; 37 38 38 - return fib6_tables_dump(net, nb); 39 + return fib6_tables_dump(net, nb, extack); 39 40 } 40 41 41 42 static const struct fib_notifier_ops fib6_notifier_ops_template = {
+3 -2
net/ipv6/fib6_rules.c
··· 47 47 } 48 48 EXPORT_SYMBOL_GPL(fib6_rule_default); 49 49 50 - int fib6_rules_dump(struct net *net, struct notifier_block *nb) 50 + int fib6_rules_dump(struct net *net, struct notifier_block *nb, 51 + struct netlink_ext_ack *extack) 51 52 { 52 - return fib_rules_dump(net, nb, AF_INET6); 53 + return fib_rules_dump(net, nb, AF_INET6, extack); 53 54 } 54 55 55 56 unsigned int fib6_rules_seq_read(struct net *net)
+9 -3
net/ipv6/ip6_fib.c
··· 359 359 360 360 static int call_fib6_entry_notifier(struct notifier_block *nb, 361 361 enum fib_event_type event_type, 362 - struct fib6_info *rt) 362 + struct fib6_info *rt, 363 + struct netlink_ext_ack *extack) 363 364 { 364 365 struct fib6_entry_notifier_info info = { 366 + .info.extack = extack, 365 367 .rt = rt, 366 368 }; 367 369 ··· 403 401 struct fib6_dump_arg { 404 402 struct net *net; 405 403 struct notifier_block *nb; 404 + struct netlink_ext_ack *extack; 406 405 }; 407 406 408 407 static int fib6_rt_dump(struct fib6_info *rt, struct fib6_dump_arg *arg) 409 408 { 410 409 if (rt == arg->net->ipv6.fib6_null_entry) 411 410 return 0; 412 - return call_fib6_entry_notifier(arg->nb, FIB_EVENT_ENTRY_ADD, rt); 411 + return call_fib6_entry_notifier(arg->nb, FIB_EVENT_ENTRY_ADD, 412 + rt, arg->extack); 413 413 } 414 414 415 415 static int fib6_node_dump(struct fib6_walker *w) ··· 441 437 } 442 438 443 439 /* Called with rcu_read_lock() */ 444 - int fib6_tables_dump(struct net *net, struct notifier_block *nb) 440 + int fib6_tables_dump(struct net *net, struct notifier_block *nb, 441 + struct netlink_ext_ack *extack) 445 442 { 446 443 struct fib6_dump_arg arg; 447 444 struct fib6_walker *w; ··· 456 451 w->func = fib6_node_dump; 457 452 arg.net = net; 458 453 arg.nb = nb; 454 + arg.extack = extack; 459 455 w->args = &arg; 460 456 461 457 for (h = 0; h < FIB6_TABLE_HASHSZ; h++) {
+8 -5
net/ipv6/ip6mr.c
··· 265 265 rtnl_unlock(); 266 266 } 267 267 268 - static int ip6mr_rules_dump(struct net *net, struct notifier_block *nb) 268 + static int ip6mr_rules_dump(struct net *net, struct notifier_block *nb, 269 + struct netlink_ext_ack *extack) 269 270 { 270 - return fib_rules_dump(net, nb, RTNL_FAMILY_IP6MR); 271 + return fib_rules_dump(net, nb, RTNL_FAMILY_IP6MR, extack); 271 272 } 272 273 273 274 static unsigned int ip6mr_rules_seq_read(struct net *net) ··· 325 324 rtnl_unlock(); 326 325 } 327 326 328 - static int ip6mr_rules_dump(struct net *net, struct notifier_block *nb) 327 + static int ip6mr_rules_dump(struct net *net, struct notifier_block *nb, 328 + struct netlink_ext_ack *extack) 329 329 { 330 330 return 0; 331 331 } ··· 1258 1256 return net->ipv6.ipmr_seq + ip6mr_rules_seq_read(net); 1259 1257 } 1260 1258 1261 - static int ip6mr_dump(struct net *net, struct notifier_block *nb) 1259 + static int ip6mr_dump(struct net *net, struct notifier_block *nb, 1260 + struct netlink_ext_ack *extack) 1262 1261 { 1263 1262 return mr_dump(net, nb, RTNL_FAMILY_IP6MR, ip6mr_rules_dump, 1264 - ip6mr_mr_table_iter, &mrt_lock); 1263 + ip6mr_mr_table_iter, &mrt_lock, extack); 1265 1264 } 1266 1265 1267 1266 static struct notifier_block ip6_mr_notifier = {