int __init br_netlink_init(void) { int err; err = rtnl_link_register(&br_link_ops); if (err < 0) goto err1; err = __rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL, br_dump_ifinfo); if (err) goto err2; err = __rtnl_register(PF_BRIDGE, RTM_SETLINK, br_rtm_setlink, NULL); if (err) goto err3; err = __rtnl_register(PF_BRIDGE, RTM_NEWNEIGH, br_fdb_add, NULL); if (err) goto err3; err = __rtnl_register(PF_BRIDGE, RTM_DELNEIGH, br_fdb_delete, NULL); if (err) goto err3; err = __rtnl_register(PF_BRIDGE, RTM_GETNEIGH, NULL, br_fdb_dump); if (err) goto err3; return 0; err3: rtnl_unregister_all(PF_BRIDGE); err2: rtnl_link_unregister(&br_link_ops); err1: return err; }
int __init br_netlink_init(void) { if (__rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL, br_dump_ifinfo)) return -ENOBUFS; /* Only the first call to __rtnl_register can fail */ __rtnl_register(PF_BRIDGE, RTM_SETLINK, br_rtm_setlink, NULL); return 0; }
/** * rtnl_register - Register a rtnetlink message type * * Identical to __rtnl_register() but panics on failure. This is useful * as failure of this function is very unlikely, it can only happen due * to lack of memory when allocating the chain to store all message * handlers for a protocol. Meant for use in init functions where lack * of memory implies no sense in continueing. */ void rtnl_register(int protocol, int msgtype, rtnl_doit_func doit, rtnl_dumpit_func dumpit) { if (__rtnl_register(protocol, msgtype, doit, dumpit) < 0) panic("Unable to register rtnetlink message handler, " "protocol = %d, message type = %d\n", protocol, msgtype); }