aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/rtnetlink.h
diff options
context:
space:
mode:
authorThomas Graf <tgraf@infradead.org>2010-11-21 20:31:54 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-28 01:56:08 -0500
commitcf7afbfeb8ceb0187348d0a1a0db61305e25f05f (patch)
tree8b1c07c8ae6a5b3f6f050d3286b53b3d7d72c858 /include/net/rtnetlink.h
parent89bf67f1f080c947c92f8773482d9e57767ca292 (diff)
rtnl: make link af-specific updates atomic
As David pointed out correctly, updates to af-specific attributes are currently not atomic. If multiple changes are requested and one of them fails, previous updates may have been applied already leaving the link behind in a undefined state. This patch splits the function parse_link_af() into two functions validate_link_af() and set_link_at(). validate_link_af() is placed to validate_linkmsg() check for errors as early as possible before any changes to the link have been made. set_link_af() is called to commit the changes later. This method is not fail proof, while it is currently sufficient to make set_link_af() inerrable and thus 100% atomic, the validation function method will not be able to detect all error scenarios in the future, there will likely always be errors depending on states which are f.e. not protected by rtnl_mutex and thus may change between validation and setting. Also, instead of silently ignoring unknown address families and config blocks for address families which did not register a set function the errors EAFNOSUPPORT respectively EOPNOSUPPORT are returned to avoid comitting 4 out of 5 update requests without notifying the user. Signed-off-by: Thomas Graf <tgraf@infradead.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/rtnetlink.h')
-rw-r--r--include/net/rtnetlink.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 35be0bbcd7da..4093ca78cf60 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -92,8 +92,10 @@ extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
92 * specific netlink attributes. 92 * specific netlink attributes.
93 * @get_link_af_size: Function to calculate size of address family specific 93 * @get_link_af_size: Function to calculate size of address family specific
94 * netlink attributes exlusive the container attribute. 94 * netlink attributes exlusive the container attribute.
95 * @parse_link_af: Function to parse a IFLA_AF_SPEC attribute and modify 95 * @validate_link_af: Validate a IFLA_AF_SPEC attribute, must check attr
96 * net_device accordingly. 96 * for invalid configuration settings.
97 * @set_link_af: Function to parse a IFLA_AF_SPEC attribute and modify
98 * net_device accordingly.
97 */ 99 */
98struct rtnl_af_ops { 100struct rtnl_af_ops {
99 struct list_head list; 101 struct list_head list;
@@ -103,8 +105,10 @@ struct rtnl_af_ops {
103 const struct net_device *dev); 105 const struct net_device *dev);
104 size_t (*get_link_af_size)(const struct net_device *dev); 106 size_t (*get_link_af_size)(const struct net_device *dev);
105 107
106 int (*parse_link_af)(struct net_device *dev, 108 int (*validate_link_af)(const struct net_device *dev,
107 const struct nlattr *attr); 109 const struct nlattr *attr);
110 int (*set_link_af)(struct net_device *dev,
111 const struct nlattr *attr);
108}; 112};
109 113
110extern int __rtnl_af_register(struct rtnl_af_ops *ops); 114extern int __rtnl_af_register(struct rtnl_af_ops *ops);