hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/openvswitch/vport.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2007-2014 Nicira, Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of version 2 of the GNU General Public
6
- * License as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License for more details.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * along with this program; if not, write to the Free Software
15
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16
- * 02110-1301, USA
174 */
185
196 #include <linux/etherdevice.h>
....@@ -100,6 +87,7 @@
10087 /**
10188 * ovs_vport_locate - find a port that has already been created
10289 *
90
+ * @net: network namespace
10391 * @name: name of port to find
10492 *
10593 * Must be called with ovs or RCU read lock.
....@@ -109,7 +97,8 @@
10997 struct hlist_head *bucket = hash_bucket(net, name);
11098 struct vport *vport;
11199
112
- hlist_for_each_entry_rcu(vport, bucket, hash_node)
100
+ hlist_for_each_entry_rcu(vport, bucket, hash_node,
101
+ lockdep_ovsl_is_held())
113102 if (!strcmp(name, ovs_vport_name(vport)) &&
114103 net_eq(ovs_dp_get_net(vport->dp), net))
115104 return vport;
....@@ -129,7 +118,7 @@
129118 * vport_free().
130119 */
131120 struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
132
- const struct vport_parms *parms)
121
+ const struct vport_parms *parms)
133122 {
134123 struct vport *vport;
135124 size_t alloc_size;
....@@ -261,8 +250,6 @@
261250 */
262251 void ovs_vport_del(struct vport *vport)
263252 {
264
- ASSERT_OVSL();
265
-
266253 hlist_del_rcu(&vport->hash_node);
267254 module_put(vport->ops->owner);
268255 vport->ops->destroy(vport);
....@@ -319,7 +306,7 @@
319306 if (!vport->ops->get_options)
320307 return 0;
321308
322
- nla = nla_nest_start(skb, OVS_VPORT_ATTR_OPTIONS);
309
+ nla = nla_nest_start_noflag(skb, OVS_VPORT_ATTR_OPTIONS);
323310 if (!nla)
324311 return -EMSGSIZE;
325312
....@@ -410,7 +397,8 @@
410397 *
411398 * Returns the portid of the target socket. Must be called with rcu_read_lock.
412399 */
413
-u32 ovs_vport_find_upcall_portid(const struct vport *vport, struct sk_buff *skb)
400
+u32 ovs_vport_find_upcall_portid(const struct vport *vport,
401
+ struct sk_buff *skb)
414402 {
415403 struct vport_portids *ids;
416404 u32 ids_index;
....@@ -418,8 +406,9 @@
418406
419407 ids = rcu_dereference(vport->upcall_portids);
420408
421
- if (ids->n_ids == 1 && ids->ids[0] == 0)
422
- return 0;
409
+ /* If there is only one portid, select it in the fast-path. */
410
+ if (ids->n_ids == 1)
411
+ return ids->ids[0];
423412
424413 hash = skb_get_hash(skb);
425414 ids_index = hash - ids->n_ids * reciprocal_divide(hash, ids->rn_ids);
....@@ -431,7 +420,7 @@
431420 *
432421 * @vport: vport that received the packet
433422 * @skb: skb that was received
434
- * @tun_key: tunnel (if any) that carried packet
423
+ * @tun_info: tunnel (if any) that carried packet
435424 *
436425 * Must be called with rcu_read_lock. The packet cannot be shared and
437426 * skb->data should point to the Ethernet header.
....@@ -514,6 +503,7 @@
514503 }
515504
516505 skb->dev = vport->dev;
506
+ skb->tstamp = 0;
517507 vport->ops->send(skb);
518508 return;
519509