* RTM_SETLINK when rtnl_link_build_change_request() is called.
*/
const int ao_override_rtm;
+
+ /** Called if a link message is sent to the kernel. Must append the
+ * link protocol specific attributes to the message. (IFLA_PROTINFO) */
+ int (*ao_fill_pi)(struct rtnl_link *,
+ struct nl_msg *msg, void *);
+
+ /** PROTINFO type
+ *
+ * Called if a link message is sent to the kernel. If this is set,
+ * the default IFLA_PROTINFO is bitmasked with what is specified
+ * here. (eg. NLA_F_NESTED)
+ */
+ const int ao_fill_pi_flags;
};
extern struct rtnl_link_af_ops *rtnl_link_af_ops_lookup(unsigned int);
return 0;
}
+static int af_fill_pi(struct rtnl_link *link, struct rtnl_link_af_ops *ops,
+ void *data, void *arg)
+{
+ struct nl_msg *msg = arg;
+ struct nlattr *pi_attr;
+ int err, pi_type = IFLA_PROTINFO;
+
+ if (!ops->ao_fill_pi)
+ return 0;
+
+ if (ops->ao_fill_pi_flags > 0)
+ pi_type |= ops->ao_fill_pi_flags;
+
+ if (!(pi_attr = nla_nest_start(msg, pi_type)))
+ return -NLE_MSGSIZE;
+
+ if ((err = ops->ao_fill_pi(link, arg, data)) < 0)
+ return err;
+
+ nla_nest_end(msg, pi_attr);
+
+ return 0;
+}
+
static int af_dump_line(struct rtnl_link *link, struct rtnl_link_af_ops *ops,
void *data, void *arg)
{
nla_nest_end(msg, info);
}
+ if (do_foreach_af(link, af_fill_pi, msg) < 0)
+ goto nla_put_failure;
+
if (!(af_spec = nla_nest_start(msg, IFLA_AF_SPEC)))
goto nla_put_failure;