Jesse Gross says: ==================== A few miscellaneous improvements and cleanups before the GRE tunnel integration series. Intended for net-next/3.11. ====================
Unified · Split
| @@ -192,7 +192,6 @@ enum ovs_vport_type { · 191 unmodified lines | ||
| 192 | 192 | * optional; if not specified a free port number is automatically selected. |
| 193 | 193 | * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type |
| 194 | 194 | * of vport. |
| 195 | − * and other attributes are ignored. | |
| 196 | 195 | * |
| 197 | 196 | * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to |
| 198 | 197 | * look up the vport to operate on; otherwise dp_idx from the &struct |
| @@ -130,9 +130,13 @@ static int set_eth_addr(struct sk_buff *skb, · 129 unmodified lines | ||
| 130 | 130 | if (unlikely(err)) |
| 131 | 131 | return err; |
| 132 | 132 | |
| 133 | + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2); | |
| 134 | + | |
| 133 | 135 | memcpy(eth_hdr(skb)->h_source, eth_key->eth_src, ETH_ALEN); |
| 134 | 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 | 140 | return 0; |
| 137 | 141 | } |
| 138 | 142 | |
| @@ -739,10 +739,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) · 738 unmodified lines | ||
| 739 | 739 | if (err) |
| 740 | 740 | goto err_flow_free; |
| 741 | 741 | |
| 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]); | |
| 746 | 743 | if (err) |
| 747 | 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 | 1809 | if (IS_ERR(vport)) |
| 1813 | 1810 | goto exit_unlock; |
| 1814 | 1811 | |
| 1815 | − err = 0; | |
| 1816 | 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 | 1814 | err = -EINVAL; |
| 1815 | + goto exit_unlock; | |
| 1816 | + } | |
| 1819 | 1817 | |
| 1820 | 1818 | reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
| 1821 | 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 | 1821 | goto exit_unlock; |
| 1824 | 1822 | } |
| 1825 | 1823 | |
| 1826 | − if (!err && a[OVS_VPORT_ATTR_OPTIONS]) | |
| 1824 | + if (a[OVS_VPORT_ATTR_OPTIONS]) { | |
| 1827 | 1825 | 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 | + } | |
| 1830 | 1829 | |
| 1831 | 1830 | if (a[OVS_VPORT_ATTR_UPCALL_PID]) |
| 1832 | 1831 | vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]); |
| @@ -590,10 +590,10 @@ out: · 589 unmodified lines | ||
| 590 | 590 | * - skb->network_header: just past the Ethernet header, or just past the |
| 591 | 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_IPV6 | |
| 593 | + * - skb->transport_header: If key->eth.type is ETH_P_IP or ETH_P_IPV6 | |
| 594 | 594 | * on output, then just past the IP header, if one is present and |
| 595 | 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 | */ |
| 598 | 598 | int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key, |
| 599 | 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 | 618 | memcpy(key->eth.dst, eth->h_dest, ETH_ALEN); |
| 619 | 619 | |
| 620 | 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 | 625 | if (vlan_tx_tag_present(skb)) |
| 623 | 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 | 1127 | * 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 | |
| 1129 | 1130 | * sequence. |
| 1130 | 1131 | * |
| 1131 | 1132 | * 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 | 1134 | * get the metadata, that is, the parts of the flow key that cannot be |
| 1134 | 1135 | * extracted from the packet itself. |
| 1135 | 1136 | */ |
| 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) | |
| 1138 | 1139 | { |
| 1139 | 1140 | const struct nlattr *nla; |
| 1140 | 1141 | int rem; |
| 1141 | 1142 | |
| 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; | |
| 1145 | 1146 | |
| 1146 | 1147 | nla_for_each_nested(nla, attr, rem) { |
| 1147 | 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 | 1154 | switch (type) { |
| 1154 | 1155 | case OVS_KEY_ATTR_PRIORITY: |
| 1155 | − *priority = nla_get_u32(nla); | |
| 1156 | + flow->key.phy.priority = nla_get_u32(nla); | |
| 1156 | 1157 | break; |
| 1157 | 1158 | |
| 1158 | 1159 | case OVS_KEY_ATTR_IN_PORT: |
| 1159 | 1160 | if (nla_get_u32(nla) >= DP_MAX_PORTS) |
| 1160 | 1161 | return -EINVAL; |
| 1161 | − *in_port = nla_get_u32(nla); | |
| 1162 | + flow->key.phy.in_port = nla_get_u32(nla); | |
| 1162 | 1163 | break; |
| 1163 | 1164 | |
| 1164 | 1165 | case OVS_KEY_ATTR_SKB_MARK: |
| 1165 | − *mark = nla_get_u32(nla); | |
| 1166 | + flow->key.phy.skb_mark = nla_get_u32(nla); | |
| 1166 | 1167 | break; |
| 1167 | 1168 | } |
| 1168 | 1169 | } |
| @@ -141,8 +141,8 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies); · 140 unmodified lines | ||
| 141 | 141 | int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *); |
| 142 | 142 | int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, |
| 143 | 143 | 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); | |
| 146 | 146 | |
| 147 | 147 | #define MAX_ACTIONS_BUFSIZE (16 * 1024) |
| 148 | 148 | #define TBL_MIN_BUCKETS 1024 |
| @@ -221,6 +221,7 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb) · 220 unmodified lines | ||
| 221 | 221 | skb->dev = netdev; |
| 222 | 222 | skb->pkt_type = PACKET_HOST; |
| 223 | 223 | skb->protocol = eth_type_trans(skb, netdev); |
| 224 | + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); | |
| 224 | 225 | |
| 225 | 226 | netif_rx(skb); |
| 226 | 227 | |
| @@ -49,6 +49,8 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) · 48 unmodified lines | ||
| 49 | 49 | return; |
| 50 | 50 | |
| 51 | 51 | skb_push(skb, ETH_HLEN); |
| 52 | + ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN); | |
| 53 | + | |
| 52 | 54 | ovs_vport_receive(vport, skb); |
| 53 | 55 | return; |
| 54 | 56 | |
| @@ -170,7 +172,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) · 115 unmodified lines | ||
| 170 | 172 | net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n", |
| 171 | 173 | netdev_vport->dev->name, |
| 172 | 174 | packet_length(skb), mtu); |
| 173 | − goto error; | |
| 175 | + goto drop; | |
| 174 | 176 | } |
| 175 | 177 | |
| 176 | 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 | 182 | return len; |
| 181 | 183 | |
| 182 | −error: | |
| 184 | +drop: | |
| 183 | 185 | kfree_skb(skb); |
| 184 | − ovs_vport_record_error(vport, VPORT_E_TX_DROPPED); | |
| 185 | 186 | return 0; |
| 186 | 187 | } |
| 187 | 188 | |
| @@ -39,6 +39,5 @@ netdev_vport_priv(const struct vport *vport) · 38 unmodified lines | ||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | const char *ovs_netdev_get_name(const struct vport *); |
| 42 | −const char *ovs_netdev_get_config(const struct vport *); | |
| 43 | 42 | |
| 44 | 43 | #endif /* vport_netdev.h */ |
| @@ -351,7 +351,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) · 350 unmodified lines | ||
| 351 | 351 | { |
| 352 | 352 | int sent = vport->ops->send(vport, skb); |
| 353 | 353 | |
| 354 | − if (likely(sent)) { | |
| 354 | + if (likely(sent > 0)) { | |
| 355 | 355 | struct pcpu_tstats *stats; |
| 356 | 356 | |
| 357 | 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 | 360 | stats->tx_packets++; |
| 361 | 361 | stats->tx_bytes += sent; |
| 362 | 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 | 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 | 376 | * @err_type: one of enum vport_err_type types to indicate the error type |
| 372 | 377 | * |
| 373 | 378 | * If using the vport generic stats layer indicate that an error of the given |
| 374 | − * type has occured. | |
| 379 | + * type has occurred. | |
| 375 | 380 | */ |
| 376 | 381 | void ovs_vport_record_error(struct vport *vport, enum vport_err_type err_type) |
| 377 | 382 | { |
| @@ -123,9 +123,8 @@ struct vport_parms { · 122 unmodified lines | ||
| 123 | 123 | * existing vport to a &struct sk_buff. May be %NULL for a vport that does not |
| 124 | 124 | * have any configuration. |
| 125 | 125 | * @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. | |
| 129 | 128 | */ |
| 130 | 129 | struct vport_ops { |
| 131 | 130 | enum ovs_vport_type type; |
| @@ -139,7 +138,6 @@ struct vport_ops { · 7 unmodified lines | ||
| 139 | 138 | |
| 140 | 139 | /* Called with rcu_read_lock or ovs_mutex. */ |
| 141 | 140 | const char *(*get_name)(const struct vport *); |
| 142 | − void (*get_config)(const struct vport *, void *); | |
| 143 | 141 | |
| 144 | 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 | ||
| 194 | 192 | extern const struct vport_ops ovs_netdev_vport_ops; |
| 195 | 193 | extern const struct vport_ops ovs_internal_vport_ops; |
| 196 | 194 | |
| 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 | + | |
| 197 | 202 | #endif /* vport.h */ |