diff options
author | Taehee Yoo <ap420073@gmail.com> | 2019-07-05 12:08:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-07-12 18:16:58 -0400 |
commit | 6b660c4177aaebdc73df7a3378f0e8b110aa4b51 (patch) | |
tree | e777999ba2b119bc5a47aa746a2a9e273b8f5d5d | |
parent | 9db7e618fca34d0a7d61c149d726fd90644ecb1e (diff) |
net: openvswitch: do not update max_headroom if new headroom is equal to old headroom
When a vport is deleted, the maximum headroom size would be changed.
If the vport which has the largest headroom is deleted,
the new max_headroom would be set.
But, if the new headroom size is equal to the old headroom size,
updating routine is unnecessary.
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/openvswitch/datapath.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 33b388103741..892287d06c17 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -1958,10 +1958,9 @@ static struct vport *lookup_vport(struct net *net, | |||
1958 | 1958 | ||
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | /* Called with ovs_mutex */ | 1961 | static unsigned int ovs_get_max_headroom(struct datapath *dp) |
1962 | static void update_headroom(struct datapath *dp) | ||
1963 | { | 1962 | { |
1964 | unsigned dev_headroom, max_headroom = 0; | 1963 | unsigned int dev_headroom, max_headroom = 0; |
1965 | struct net_device *dev; | 1964 | struct net_device *dev; |
1966 | struct vport *vport; | 1965 | struct vport *vport; |
1967 | int i; | 1966 | int i; |
@@ -1975,10 +1974,19 @@ static void update_headroom(struct datapath *dp) | |||
1975 | } | 1974 | } |
1976 | } | 1975 | } |
1977 | 1976 | ||
1978 | dp->max_headroom = max_headroom; | 1977 | return max_headroom; |
1978 | } | ||
1979 | |||
1980 | /* Called with ovs_mutex */ | ||
1981 | static void ovs_update_headroom(struct datapath *dp, unsigned int new_headroom) | ||
1982 | { | ||
1983 | struct vport *vport; | ||
1984 | int i; | ||
1985 | |||
1986 | dp->max_headroom = new_headroom; | ||
1979 | for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) | 1987 | for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) |
1980 | hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) | 1988 | hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) |
1981 | netdev_set_rx_headroom(vport->dev, max_headroom); | 1989 | netdev_set_rx_headroom(vport->dev, new_headroom); |
1982 | } | 1990 | } |
1983 | 1991 | ||
1984 | static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) | 1992 | static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) |
@@ -1989,6 +1997,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) | |||
1989 | struct sk_buff *reply; | 1997 | struct sk_buff *reply; |
1990 | struct vport *vport; | 1998 | struct vport *vport; |
1991 | struct datapath *dp; | 1999 | struct datapath *dp; |
2000 | unsigned int new_headroom; | ||
1992 | u32 port_no; | 2001 | u32 port_no; |
1993 | int err; | 2002 | int err; |
1994 | 2003 | ||
@@ -2050,8 +2059,10 @@ restart: | |||
2050 | info->snd_portid, info->snd_seq, 0, | 2059 | info->snd_portid, info->snd_seq, 0, |
2051 | OVS_VPORT_CMD_NEW); | 2060 | OVS_VPORT_CMD_NEW); |
2052 | 2061 | ||
2053 | if (netdev_get_fwd_headroom(vport->dev) > dp->max_headroom) | 2062 | new_headroom = netdev_get_fwd_headroom(vport->dev); |
2054 | update_headroom(dp); | 2063 | |
2064 | if (new_headroom > dp->max_headroom) | ||
2065 | ovs_update_headroom(dp, new_headroom); | ||
2055 | else | 2066 | else |
2056 | netdev_set_rx_headroom(vport->dev, dp->max_headroom); | 2067 | netdev_set_rx_headroom(vport->dev, dp->max_headroom); |
2057 | 2068 | ||
@@ -2122,11 +2133,12 @@ exit_unlock_free: | |||
2122 | 2133 | ||
2123 | static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info) | 2134 | static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info) |
2124 | { | 2135 | { |
2125 | bool must_update_headroom = false; | 2136 | bool update_headroom = false; |
2126 | struct nlattr **a = info->attrs; | 2137 | struct nlattr **a = info->attrs; |
2127 | struct sk_buff *reply; | 2138 | struct sk_buff *reply; |
2128 | struct datapath *dp; | 2139 | struct datapath *dp; |
2129 | struct vport *vport; | 2140 | struct vport *vport; |
2141 | unsigned int new_headroom; | ||
2130 | int err; | 2142 | int err; |
2131 | 2143 | ||
2132 | reply = ovs_vport_cmd_alloc_info(); | 2144 | reply = ovs_vport_cmd_alloc_info(); |
@@ -2152,12 +2164,17 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info) | |||
2152 | /* the vport deletion may trigger dp headroom update */ | 2164 | /* the vport deletion may trigger dp headroom update */ |
2153 | dp = vport->dp; | 2165 | dp = vport->dp; |
2154 | if (netdev_get_fwd_headroom(vport->dev) == dp->max_headroom) | 2166 | if (netdev_get_fwd_headroom(vport->dev) == dp->max_headroom) |
2155 | must_update_headroom = true; | 2167 | update_headroom = true; |
2168 | |||
2156 | netdev_reset_rx_headroom(vport->dev); | 2169 | netdev_reset_rx_headroom(vport->dev); |
2157 | ovs_dp_detach_port(vport); | 2170 | ovs_dp_detach_port(vport); |
2158 | 2171 | ||
2159 | if (must_update_headroom) | 2172 | if (update_headroom) { |
2160 | update_headroom(dp); | 2173 | new_headroom = ovs_get_max_headroom(dp); |
2174 | |||
2175 | if (new_headroom < dp->max_headroom) | ||
2176 | ovs_update_headroom(dp, new_headroom); | ||
2177 | } | ||
2161 | ovs_unlock(); | 2178 | ovs_unlock(); |
2162 | 2179 | ||
2163 | ovs_notify(&dp_vport_genl_family, reply, info); | 2180 | ovs_notify(&dp_vport_genl_family, reply, info); |