History

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch

Jesse Gross says: ==================== A few miscellaneous improvements and cleanups before the GRE tunnel integration series. Intended for net-next/3.11. ====================

David S. Miller committed 13 years ago

Commit 09ce0692 parents 948e306 93d8fd110 files · +51 −37Browse files

Unified · Split

10 files
  1. include/uapi/linux/openvswitch.h +0 −1
  2. net/openvswitch/actions.c +4 −0
  3. net/openvswitch/datapath.c +8 −9
  4. net/openvswitch/flow.c +15 −14
  5. net/openvswitch/flow.h +2 −2
  6. net/openvswitch/vport-internal_dev.c +1 −0
  7. net/openvswitch/vport-netdev.c +4 −3
  8. net/openvswitch/vport-netdev.h +0 −1
  9. net/openvswitch/vport.c +8 −3
  10. net/openvswitch/vport.h +9 −4
include/uapi/linux/openvswitch.h+0−1
@@ -192,7 +192,6 @@ enum ovs_vport_type { · 191 unmodified lines
192192 * optional; if not specified a free port number is automatically selected.
193193 * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type
194194 * of vport.
195− * and other attributes are ignored.
196195 *
197196 * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to
198197 * look up the vport to operate on; otherwise dp_idx from the &struct
net/openvswitch/actions.c+4−0
@@ -130,9 +130,13 @@ static int set_eth_addr(struct sk_buff *skb, · 129 unmodified lines
130130 if (unlikely(err))
131131 return err;
132132
133+ skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
134+
133135 memcpy(eth_hdr(skb)->h_source, eth_key->eth_src, ETH_ALEN);
134136 memcpy(eth_hdr(skb)->h_dest, eth_key->eth_dst, ETH_ALEN);
135137
138+ ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
139+
136140 return 0;
137141 }
138142
net/openvswitch/datapath.c+8−9
@@ -739,10 +739,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) · 738 unmodified lines
739739 if (err)
740740 goto err_flow_free;
741741
742− err = ovs_flow_metadata_from_nlattrs(&flow->key.phy.priority,
743− &flow->key.phy.skb_mark,
744− &flow->key.phy.in_port,
745− a[OVS_PACKET_ATTR_KEY]);
742+ err = ovs_flow_metadata_from_nlattrs(flow, a[OVS_PACKET_ATTR_KEY]);
746743 if (err)
747744 goto err_flow_free;
748745
@@ -1812,10 +1809,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) · 1063 unmodified lines
18121809 if (IS_ERR(vport))
18131810 goto exit_unlock;
18141811
1815− err = 0;
18161812 if (a[OVS_VPORT_ATTR_TYPE] &&
1817− nla_get_u32(a[OVS_VPORT_ATTR_TYPE]) != vport->ops->type)
1813+ nla_get_u32(a[OVS_VPORT_ATTR_TYPE]) != vport->ops->type) {
18181814 err = -EINVAL;
1815+ goto exit_unlock;
1816+ }
18191817
18201818 reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
18211819 if (!reply) {
@@ -1823,10 +1821,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) · 1 unmodified line
18231821 goto exit_unlock;
18241822 }
18251823
1826− if (!err && a[OVS_VPORT_ATTR_OPTIONS])
1824+ if (a[OVS_VPORT_ATTR_OPTIONS]) {
18271825 err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]);
1828− if (err)
1829− goto exit_free;
1826+ if (err)
1827+ goto exit_free;
1828+ }
18301829
18311830 if (a[OVS_VPORT_ATTR_UPCALL_PID])
18321831 vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);
net/openvswitch/flow.c+15−14
@@ -590,10 +590,10 @@ out: · 589 unmodified lines
590590 * - skb->network_header: just past the Ethernet header, or just past the
591591 * VLAN header, to the first byte of the Ethernet payload.
592592 *
593− * - skb->transport_header: If key->dl_type is ETH_P_IP or ETH_P_IPV6
593+ * - skb->transport_header: If key->eth.type is ETH_P_IP or ETH_P_IPV6
594594 * on output, then just past the IP header, if one is present and
595595 * of a correct length, otherwise the same as skb->network_header.
596− * For other key->dl_type values it is left untouched.
596+ * For other key->eth.type values it is left untouched.
597597 */
598598 int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
599599 int *key_lenp)
@@ -618,6 +618,9 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key, · 18 unmodified lines
618618 memcpy(key->eth.dst, eth->h_dest, ETH_ALEN);
619619
620620 __skb_pull(skb, 2 * ETH_ALEN);
621+ /* We are going to push all headers that we pull, so no need to
622+ * update skb->csum here.
623+ */
621624
622625 if (vlan_tx_tag_present(skb))
623626 key->eth.tci = htons(skb->vlan_tci);
@@ -1122,10 +1125,8 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, · 498 unmodified lines
11221125
11231126 /**
11241127 * ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key.
1125− * @priority: receives the skb priority
1126− * @mark: receives the skb mark
1127− * @in_port: receives the extracted input port.
1128− * @key: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
1128+ * @flow: Receives extracted in_port, priority, tun_key and skb_mark.
1129+ * @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
11291130 * sequence.
11301131 *
11311132 * This parses a series of Netlink attributes that form a flow key, which must
@@ -1133,15 +1134,15 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, · 1 unmodified line
11331134 * get the metadata, that is, the parts of the flow key that cannot be
11341135 * extracted from the packet itself.
11351136 */
1136−int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,
1137− const struct nlattr *attr)
1137+int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
1138+ const struct nlattr *attr)
11381139 {
11391140 const struct nlattr *nla;
11401141 int rem;
11411142
1142− *in_port = DP_MAX_PORTS;
1143− *priority = 0;
1144− *mark = 0;
1143+ flow->key.phy.in_port = DP_MAX_PORTS;
1144+ flow->key.phy.priority = 0;
1145+ flow->key.phy.skb_mark = 0;
11451146
11461147 nla_for_each_nested(nla, attr, rem) {
11471148 int type = nla_type(nla);
@@ -1152,17 +1153,17 @@ int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port, · 4 unmodified lines
11521153
11531154 switch (type) {
11541155 case OVS_KEY_ATTR_PRIORITY:
1155− *priority = nla_get_u32(nla);
1156+ flow->key.phy.priority = nla_get_u32(nla);
11561157 break;
11571158
11581159 case OVS_KEY_ATTR_IN_PORT:
11591160 if (nla_get_u32(nla) >= DP_MAX_PORTS)
11601161 return -EINVAL;
1161− *in_port = nla_get_u32(nla);
1162+ flow->key.phy.in_port = nla_get_u32(nla);
11621163 break;
11631164
11641165 case OVS_KEY_ATTR_SKB_MARK:
1165− *mark = nla_get_u32(nla);
1166+ flow->key.phy.skb_mark = nla_get_u32(nla);
11661167 break;
11671168 }
11681169 }
net/openvswitch/flow.h+2−2
@@ -141,8 +141,8 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies); · 140 unmodified lines
141141 int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);
142142 int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
143143 const struct nlattr *);
144−int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,
145− const struct nlattr *);
144+int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
145+ const struct nlattr *attr);
146146
147147 #define MAX_ACTIONS_BUFSIZE (16 * 1024)
148148 #define TBL_MIN_BUCKETS 1024
net/openvswitch/vport-internal_dev.c+1−0
@@ -221,6 +221,7 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb) · 220 unmodified lines
221221 skb->dev = netdev;
222222 skb->pkt_type = PACKET_HOST;
223223 skb->protocol = eth_type_trans(skb, netdev);
224+ skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
224225
225226 netif_rx(skb);
226227
net/openvswitch/vport-netdev.c+4−3
@@ -49,6 +49,8 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) · 48 unmodified lines
4949 return;
5050
5151 skb_push(skb, ETH_HLEN);
52+ ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
53+
5254 ovs_vport_receive(vport, skb);
5355 return;
5456
@@ -170,7 +172,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) · 115 unmodified lines
170172 net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
171173 netdev_vport->dev->name,
172174 packet_length(skb), mtu);
173− goto error;
175+ goto drop;
174176 }
175177
176178 skb->dev = netdev_vport->dev;
@@ -179,9 +181,8 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) · 2 unmodified lines
179181
180182 return len;
181183
182−error:
184+drop:
183185 kfree_skb(skb);
184− ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
185186 return 0;
186187 }
187188
net/openvswitch/vport-netdev.h+0−1
@@ -39,6 +39,5 @@ netdev_vport_priv(const struct vport *vport) · 38 unmodified lines
3939 }
4040
4141 const char *ovs_netdev_get_name(const struct vport *);
42−const char *ovs_netdev_get_config(const struct vport *);
4342
4443 #endif /* vport_netdev.h */
net/openvswitch/vport.c+8−3
@@ -351,7 +351,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) · 350 unmodified lines
351351 {
352352 int sent = vport->ops->send(vport, skb);
353353
354− if (likely(sent)) {
354+ if (likely(sent > 0)) {
355355 struct pcpu_tstats *stats;
356356
357357 stats = this_cpu_ptr(vport->percpu_stats);
@@ -360,7 +360,12 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) · 2 unmodified lines
360360 stats->tx_packets++;
361361 stats->tx_bytes += sent;
362362 u64_stats_update_end(&stats->syncp);
363− }
363+ } else if (sent < 0) {
364+ ovs_vport_record_error(vport, VPORT_E_TX_ERROR);
365+ kfree_skb(skb);
366+ } else
367+ ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
368+
364369 return sent;
365370 }
366371
@@ -371,7 +376,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) · 4 unmodified lines
371376 * @err_type: one of enum vport_err_type types to indicate the error type
372377 *
373378 * If using the vport generic stats layer indicate that an error of the given
374− * type has occured.
379+ * type has occurred.
375380 */
376381 void ovs_vport_record_error(struct vport *vport, enum vport_err_type err_type)
377382 {
net/openvswitch/vport.h+9−4
@@ -123,9 +123,8 @@ struct vport_parms { · 122 unmodified lines
123123 * existing vport to a &struct sk_buff. May be %NULL for a vport that does not
124124 * have any configuration.
125125 * @get_name: Get the device's name.
126− * @get_config: Get the device's configuration.
127− * May be null if the device does not have an ifindex.
128− * @send: Send a packet on the device. Returns the length of the packet sent.
126+ * @send: Send a packet on the device. Returns the length of the packet sent,
127+ * zero for dropped packets or negative for error.
129128 */
130129 struct vport_ops {
131130 enum ovs_vport_type type;
@@ -139,7 +138,6 @@ struct vport_ops { · 7 unmodified lines
139138
140139 /* Called with rcu_read_lock or ovs_mutex. */
141140 const char *(*get_name)(const struct vport *);
142− void (*get_config)(const struct vport *, void *);
143141
144142 int (*send)(struct vport *, struct sk_buff *);
145143 };
@@ -194,4 +192,11 @@ void ovs_vport_record_error(struct vport *, enum vport_err_type err_type); · 48 unmodified lines
194192 extern const struct vport_ops ovs_netdev_vport_ops;
195193 extern const struct vport_ops ovs_internal_vport_ops;
196194
195+static inline void ovs_skb_postpush_rcsum(struct sk_buff *skb,
196+ const void *start, unsigned int len)
197+{
198+ if (skb->ip_summed == CHECKSUM_COMPLETE)
199+ skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
200+}
201+
197202 #endif /* vport.h */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t