aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/rtnetlink.h3
-rw-r--r--include/net/netlink.h17
-rw-r--r--net/core/rtnetlink.c18
3 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 0e4f478e2cb5..ecbe0349060c 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -585,6 +585,9 @@ struct rtnetlink_link
585extern struct rtnetlink_link * rtnetlink_links[NPROTO]; 585extern struct rtnetlink_link * rtnetlink_links[NPROTO];
586extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo); 586extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
587extern int rtnl_unicast(struct sk_buff *skb, u32 pid); 587extern int rtnl_unicast(struct sk_buff *skb, u32 pid);
588extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
589 struct nlmsghdr *nlh, gfp_t flags);
590extern void rtnl_set_sk_err(u32 group, int error);
588extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); 591extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
589 592
590extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data); 593extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
diff --git a/include/net/netlink.h b/include/net/netlink.h
index b154b81d9a7a..bf593eb59e1b 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -65,6 +65,9 @@
65 * nlmsg_validate() validate netlink message incl. attrs 65 * nlmsg_validate() validate netlink message incl. attrs
66 * nlmsg_for_each_attr() loop over all attributes 66 * nlmsg_for_each_attr() loop over all attributes
67 * 67 *
68 * Misc:
69 * nlmsg_report() report back to application?
70 *
68 * ------------------------------------------------------------------------ 71 * ------------------------------------------------------------------------
69 * Attributes Interface 72 * Attributes Interface
70 * ------------------------------------------------------------------------ 73 * ------------------------------------------------------------------------
@@ -194,6 +197,9 @@ extern void netlink_run_queue(struct sock *sk, unsigned int *qlen,
194 struct nlmsghdr *, int *)); 197 struct nlmsghdr *, int *));
195extern void netlink_queue_skip(struct nlmsghdr *nlh, 198extern void netlink_queue_skip(struct nlmsghdr *nlh,
196 struct sk_buff *skb); 199 struct sk_buff *skb);
200extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb,
201 u32 pid, unsigned int group, int report,
202 gfp_t flags);
197 203
198extern int nla_validate(struct nlattr *head, int len, int maxtype, 204extern int nla_validate(struct nlattr *head, int len, int maxtype,
199 struct nla_policy *policy); 205 struct nla_policy *policy);
@@ -376,6 +382,17 @@ static inline int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
376} 382}
377 383
378/** 384/**
385 * nlmsg_report - need to report back to application?
386 * @nlh: netlink message header
387 *
388 * Returns 1 if a report back to the application is requested.
389 */
390static inline int nlmsg_report(struct nlmsghdr *nlh)
391{
392 return !!(nlh->nlmsg_flags & NLM_F_ECHO);
393}
394
395/**
379 * nlmsg_for_each_attr - iterate over a stream of attributes 396 * nlmsg_for_each_attr - iterate over a stream of attributes
380 * @pos: loop counter, set to current attribute 397 * @pos: loop counter, set to current attribute
381 * @nlh: netlink message header 398 * @nlh: netlink message header
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e02fa6a33f42..2b1af17e6389 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -171,6 +171,22 @@ int rtnl_unicast(struct sk_buff *skb, u32 pid)
171 return nlmsg_unicast(rtnl, skb, pid); 171 return nlmsg_unicast(rtnl, skb, pid);
172} 172}
173 173
174int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
175 struct nlmsghdr *nlh, gfp_t flags)
176{
177 int report = 0;
178
179 if (nlh)
180 report = nlmsg_report(nlh);
181
182 return nlmsg_notify(rtnl, skb, pid, group, report, flags);
183}
184
185void rtnl_set_sk_err(u32 group, int error)
186{
187 netlink_set_err(rtnl, 0, group, error);
188}
189
174int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics) 190int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
175{ 191{
176 struct rtattr *mx = (struct rtattr*)skb->tail; 192 struct rtattr *mx = (struct rtattr*)skb->tail;
@@ -829,3 +845,5 @@ EXPORT_SYMBOL(rtnl_lock);
829EXPORT_SYMBOL(rtnl_trylock); 845EXPORT_SYMBOL(rtnl_trylock);
830EXPORT_SYMBOL(rtnl_unlock); 846EXPORT_SYMBOL(rtnl_unlock);
831EXPORT_SYMBOL(rtnl_unicast); 847EXPORT_SYMBOL(rtnl_unicast);
848EXPORT_SYMBOL(rtnl_notify);
849EXPORT_SYMBOL(rtnl_set_sk_err);