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
192 * optional; if not specified a free port number is automatically selected.192 * optional; if not specified a free port number is automatically selected.
193 * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type193 * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type
194 * of vport.194 * of vport.
195 * and other attributes are ignored.
196 *195 *
197 * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to196 * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to
198 * look up the vport to operate on; otherwise dp_idx from the &struct197 * 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
130 if (unlikely(err))130 if (unlikely(err))
131 return err;131 return err;
132 132
133 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
134
133 memcpy(eth_hdr(skb)->h_source, eth_key->eth_src, ETH_ALEN);135 memcpy(eth_hdr(skb)->h_source, eth_key->eth_src, ETH_ALEN);
134 memcpy(eth_hdr(skb)->h_dest, eth_key->eth_dst, ETH_ALEN);136 memcpy(eth_hdr(skb)->h_dest, eth_key->eth_dst, ETH_ALEN);
135 137
138 ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
139
136 return 0;140 return 0;
137}141}
138 142
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
739 if (err)739 if (err)
740 goto err_flow_free;740 goto err_flow_free;
741 741
742 err = ovs_flow_metadata_from_nlattrs(&flow->key.phy.priority,742 err = ovs_flow_metadata_from_nlattrs(flow, a[OVS_PACKET_ATTR_KEY]);
743 &flow->key.phy.skb_mark,
744 &flow->key.phy.in_port,
745 a[OVS_PACKET_ATTR_KEY]);
746 if (err)743 if (err)
747 goto err_flow_free;744 goto err_flow_free;
748 745
@@ -1812,10 +1809,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) · 1063 unmodified lines
1812 if (IS_ERR(vport))1809 if (IS_ERR(vport))
1813 goto exit_unlock;1810 goto exit_unlock;
1814 1811
1815 err = 0;
1816 if (a[OVS_VPORT_ATTR_TYPE] &&1812 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) {
1818 err = -EINVAL;1814 err = -EINVAL;
1815 goto exit_unlock;
1816 }
1819 1817
1820 reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);1818 reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1821 if (!reply) {1819 if (!reply) {
@@ -1823,10 +1821,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) · 1 unmodified line
1823 goto exit_unlock;1821 goto exit_unlock;
1824 }1822 }
1825 1823
1826 if (!err && a[OVS_VPORT_ATTR_OPTIONS])1824 if (a[OVS_VPORT_ATTR_OPTIONS]) {
1827 err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]);1825 err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]);
1828 if (err)1826 if (err)
1829 goto exit_free;1827 goto exit_free;
1828 }
1830 1829
1831 if (a[OVS_VPORT_ATTR_UPCALL_PID])1830 if (a[OVS_VPORT_ATTR_UPCALL_PID])
1832 vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);1831 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
590 * - skb->network_header: just past the Ethernet header, or just past the590 * - skb->network_header: just past the Ethernet header, or just past the
591 * VLAN header, to the first byte of the Ethernet payload.591 * VLAN header, to the first byte of the Ethernet payload.
592 *592 *
593 * - skb->transport_header: If key->dl_type is ETH_P_IP or ETH_P_IPV6593 * - skb->transport_header: If key->eth.type is ETH_P_IP or ETH_P_IPV6
594 * on output, then just past the IP header, if one is present and594 * on output, then just past the IP header, if one is present and
595 * of a correct length, otherwise the same as skb->network_header.595 * 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.
597 */597 */
598int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,598int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
599 int *key_lenp)599 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
618 memcpy(key->eth.dst, eth->h_dest, ETH_ALEN);618 memcpy(key->eth.dst, eth->h_dest, ETH_ALEN);
619 619
620 __skb_pull(skb, 2 * ETH_ALEN);620 __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 */
621 624
622 if (vlan_tx_tag_present(skb))625 if (vlan_tx_tag_present(skb))
623 key->eth.tci = htons(skb->vlan_tci);626 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
1122 1125
1123/**1126/**
1124 * ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key.1127 * ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key.
1125 * @priority: receives the skb priority1128 * @flow: Receives extracted in_port, priority, tun_key and skb_mark.
1126 * @mark: receives the skb mark1129 * @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
1127 * @in_port: receives the extracted input port.
1128 * @key: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
1129 * sequence.1130 * sequence.
1130 *1131 *
1131 * This parses a series of Netlink attributes that form a flow key, which must1132 * 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
1133 * get the metadata, that is, the parts of the flow key that cannot be1134 * get the metadata, that is, the parts of the flow key that cannot be
1134 * extracted from the packet itself.1135 * extracted from the packet itself.
1135 */1136 */
1136int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,1137int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
1137 const struct nlattr *attr)1138 const struct nlattr *attr)
1138{1139{
1139 const struct nlattr *nla;1140 const struct nlattr *nla;
1140 int rem;1141 int rem;
1141 1142
1142 *in_port = DP_MAX_PORTS;1143 flow->key.phy.in_port = DP_MAX_PORTS;
1143 *priority = 0;1144 flow->key.phy.priority = 0;
1144 *mark = 0;1145 flow->key.phy.skb_mark = 0;
1145 1146
1146 nla_for_each_nested(nla, attr, rem) {1147 nla_for_each_nested(nla, attr, rem) {
1147 int type = nla_type(nla);1148 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
1152 1153
1153 switch (type) {1154 switch (type) {
1154 case OVS_KEY_ATTR_PRIORITY:1155 case OVS_KEY_ATTR_PRIORITY:
1155 *priority = nla_get_u32(nla);1156 flow->key.phy.priority = nla_get_u32(nla);
1156 break;1157 break;
1157 1158
1158 case OVS_KEY_ATTR_IN_PORT:1159 case OVS_KEY_ATTR_IN_PORT:
1159 if (nla_get_u32(nla) >= DP_MAX_PORTS)1160 if (nla_get_u32(nla) >= DP_MAX_PORTS)
1160 return -EINVAL;1161 return -EINVAL;
1161 *in_port = nla_get_u32(nla);1162 flow->key.phy.in_port = nla_get_u32(nla);
1162 break;1163 break;
1163 1164
1164 case OVS_KEY_ATTR_SKB_MARK:1165 case OVS_KEY_ATTR_SKB_MARK:
1165 *mark = nla_get_u32(nla);1166 flow->key.phy.skb_mark = nla_get_u32(nla);
1166 break;1167 break;
1167 }1168 }
1168 }1169 }
net/openvswitch/flow.h+2−2
@@ -141,8 +141,8 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies); · 140 unmodified lines
141int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);141int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);
142int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,142int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
143 const struct nlattr *);143 const struct nlattr *);
144int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,144int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
145 const struct nlattr *);145 const struct nlattr *attr);
146 146
147#define MAX_ACTIONS_BUFSIZE (16 * 1024)147#define MAX_ACTIONS_BUFSIZE (16 * 1024)
148#define TBL_MIN_BUCKETS 1024148#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
221 skb->dev = netdev;221 skb->dev = netdev;
222 skb->pkt_type = PACKET_HOST;222 skb->pkt_type = PACKET_HOST;
223 skb->protocol = eth_type_trans(skb, netdev);223 skb->protocol = eth_type_trans(skb, netdev);
224 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
224 225
225 netif_rx(skb);226 netif_rx(skb);
226 227
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
49 return;49 return;
50 50
51 skb_push(skb, ETH_HLEN);51 skb_push(skb, ETH_HLEN);
52 ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
53
52 ovs_vport_receive(vport, skb);54 ovs_vport_receive(vport, skb);
53 return;55 return;
54 56
@@ -170,7 +172,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) · 115 unmodified lines
170 net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",172 net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
171 netdev_vport->dev->name,173 netdev_vport->dev->name,
172 packet_length(skb), mtu);174 packet_length(skb), mtu);
173 goto error;175 goto drop;
174 }176 }
175 177
176 skb->dev = netdev_vport->dev;178 skb->dev = netdev_vport->dev;
@@ -179,9 +181,8 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) · 2 unmodified lines
179 181
180 return len;182 return len;
181 183
182error:184drop:
183 kfree_skb(skb);185 kfree_skb(skb);
184 ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
185 return 0;186 return 0;
186}187}
187 188
net/openvswitch/vport-netdev.h+0−1
@@ -39,6 +39,5 @@ netdev_vport_priv(const struct vport *vport) · 38 unmodified lines
39}39}
40 40
41const char *ovs_netdev_get_name(const struct vport *);41const char *ovs_netdev_get_name(const struct vport *);
42const char *ovs_netdev_get_config(const struct vport *);
43 42
44#endif /* vport_netdev.h */43#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
351{351{
352 int sent = vport->ops->send(vport, skb);352 int sent = vport->ops->send(vport, skb);
353 353
354 if (likely(sent)) {354 if (likely(sent > 0)) {
355 struct pcpu_tstats *stats;355 struct pcpu_tstats *stats;
356 356
357 stats = this_cpu_ptr(vport->percpu_stats);357 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
360 stats->tx_packets++;360 stats->tx_packets++;
361 stats->tx_bytes += sent;361 stats->tx_bytes += sent;
362 u64_stats_update_end(&stats->syncp);362 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
364 return sent;369 return sent;
365}370}
366 371
@@ -371,7 +376,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) · 4 unmodified lines
371 * @err_type: one of enum vport_err_type types to indicate the error type376 * @err_type: one of enum vport_err_type types to indicate the error type
372 *377 *
373 * If using the vport generic stats layer indicate that an error of the given378 * If using the vport generic stats layer indicate that an error of the given
374 * type has occured.379 * type has occurred.
375 */380 */
376void ovs_vport_record_error(struct vport *vport, enum vport_err_type err_type)381void ovs_vport_record_error(struct vport *vport, enum vport_err_type err_type)
377{382{
net/openvswitch/vport.h+9−4
@@ -123,9 +123,8 @@ struct vport_parms { · 122 unmodified lines
123 * existing vport to a &struct sk_buff. May be %NULL for a vport that does not123 * existing vport to a &struct sk_buff. May be %NULL for a vport that does not
124 * have any configuration.124 * have any configuration.
125 * @get_name: Get the device's name.125 * @get_name: Get the device's name.
126 * @get_config: Get the device's configuration.126 * @send: Send a packet on the device. Returns the length of the packet sent,
127 * May be null if the device does not have an ifindex.127 * zero for dropped packets or negative for error.
128 * @send: Send a packet on the device. Returns the length of the packet sent.
129 */128 */
130struct vport_ops {129struct vport_ops {
131 enum ovs_vport_type type;130 enum ovs_vport_type type;
@@ -139,7 +138,6 @@ struct vport_ops { · 7 unmodified lines
139 138
140 /* Called with rcu_read_lock or ovs_mutex. */139 /* Called with rcu_read_lock or ovs_mutex. */
141 const char *(*get_name)(const struct vport *);140 const char *(*get_name)(const struct vport *);
142 void (*get_config)(const struct vport *, void *);
143 141
144 int (*send)(struct vport *, struct sk_buff *);142 int (*send)(struct vport *, struct sk_buff *);
145};143};
@@ -194,4 +192,11 @@ void ovs_vport_record_error(struct vport *, enum vport_err_type err_type); · 48 unmodified lines
194extern const struct vport_ops ovs_netdev_vport_ops;192extern const struct vport_ops ovs_netdev_vport_ops;
195extern const struct vport_ops ovs_internal_vport_ops;193extern const struct vport_ops ovs_internal_vport_ops;
196 194
195static 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
197#endif /* vport.h */202#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