Skip to contentSkip to conversation

regression caused by 1d2024f61ec14bdb0c57a97a3fe73685abc2d198?

DISCUSSION Michael S. Tsirkin 4 participants 16 messages Feb 6, 2013 – Feb 7, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Signature · 1 line
MST
#1 lore raw
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

#2 lore raw
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 8 lines
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

Hmm, ixgbe_get_headlen isn't run on linear skbs though.

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

I see 3 in-tree drivers that do this:

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c: skb_shinfo(skb)->gso_size = bnx2x
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c: skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->le
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c: skb_shinfo(skb)->gso_size = qlcnic_get_lr

It seems likely the same issue applies there?

Signature · 1 line
MST
#3 lore raw
Quoted 8 lines · Michael S. Tsirkin

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

I see 3 in-tree drivers that do this:

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c: skb_shinfo(skb)->gso_size = bnx2x

bnx2x is fine, take a look at lines 464

Quoted 4 lines

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c: skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->le
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c: skb_shinfo(skb)->gso_size = qlcnic_get_lr

It seems likely the same issue applies there?

Yes

#4 lore raw
Quoted 7 lines · Eric Dumazet
Quoted 5 lines · Michael S. Tsirkin

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

Quoted 5 lines
Quoted 3 lines

I see 3 in-tree drivers that do this:

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c: skb_shinfo(skb)->gso_size = bnx2x

bnx2x is fine, take a look at lines 464

Is this what you mean?

        /* This is needed in order to enable forwarding support */
        if (frag_size) {
                skb_shinfo(skb)->gso_size = bnx2x_set_lro_mss(bp,
                                        tpa_info->parsing_flags, len_on_bd);

                /* set for GRO */
                if (fp->mode == TPA_MODE_GRO)
                        skb_shinfo(skb)->gso_type =
                            (GET_FLAG(tpa_info->parsing_flags,
                                      PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
                                                PRS_FLAG_OVERETH_IPV6) ?
                                SKB_GSO_TCPV6 : SKB_GSO_TCPV4;
        }

I see it sets gso_type but apparently only if mode is GRO? Will this still break if mode is set to LRO?

Quoted 6 lines
Quoted 4 lines

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c: skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->le
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c: skb_shinfo(skb)->gso_size = qlcnic_get_lr

It seems likely the same issue applies there?

Yes

#5 lore raw
Quoted 31 lines · Michael S. Tsirkin
Quoted 7 lines · Eric Dumazet
Quoted 5 lines · Michael S. Tsirkin

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

Quoted 5 lines
Quoted 3 lines

I see 3 in-tree drivers that do this:

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c: skb_shinfo(skb)->gso_size = bnx2x

bnx2x is fine, take a look at lines 464

Is this what you mean?

        /* This is needed in order to enable forwarding support */
        if (frag_size) {
                skb_shinfo(skb)->gso_size = bnx2x_set_lro_mss(bp,
                                        tpa_info->parsing_flags, len_on_bd);

                /* set for GRO */
                if (fp->mode == TPA_MODE_GRO)
                        skb_shinfo(skb)->gso_type =
                            (GET_FLAG(tpa_info->parsing_flags,
                                      PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
                                                PRS_FLAG_OVERETH_IPV6) ?
                                SKB_GSO_TCPV6 : SKB_GSO_TCPV4;
        }
Quoted 4 lines

I see it sets gso_type but apparently only if mode is GRO? Will this still break if mode is set to LRO?

In net-next tree, line 464 looks like :

static void bnx2x_set_gro_params(struct sk_buff *skb, u16 parsing_flags,
u16 len_on_bd, unsigned int pkt_len)

{
        /* TPA aggregation won't have either IP options or TCP options
         * other than timestamp or IPv6 extension headers.
         */
        u16 hdrs_len = ETH_HLEN + sizeof(struct tcphdr);

        if (GET_FLAG(parsing_flags, PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
            PRS_FLAG_OVERETH_IPV6) {
                hdrs_len += sizeof(struct ipv6hdr);
<HERE>          skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
        } else {
                hdrs_len += sizeof(struct iphdr);
<HERE>          skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
        }

        /* Check if there was a TCP timestamp, if there is it's will
         * always be 12 bytes length: nop nop kind length echo val.
         *
         * Otherwise FW would close the aggregation.
         */
        if (parsing_flags & PARSING_FLAGS_TIME_STAMP_EXIST_FLAG)
                hdrs_len += TPA_TSTAMP_OPT_LEN;

        skb_shinfo(skb)->gso_size = len_on_bd - hdrs_len;

...

#6 lore raw
Quoted 66 lines · Eric Dumazet
Quoted 31 lines · Michael S. Tsirkin
Quoted 7 lines · Eric Dumazet
Quoted 5 lines · Michael S. Tsirkin

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

Quoted 5 lines
Quoted 3 lines

I see 3 in-tree drivers that do this:

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c: skb_shinfo(skb)->gso_size = bnx2x

bnx2x is fine, take a look at lines 464

Is this what you mean?

        /* This is needed in order to enable forwarding support */
        if (frag_size) {
                skb_shinfo(skb)->gso_size = bnx2x_set_lro_mss(bp,
                                        tpa_info->parsing_flags, len_on_bd);

                /* set for GRO */
                if (fp->mode == TPA_MODE_GRO)
                        skb_shinfo(skb)->gso_type =
                            (GET_FLAG(tpa_info->parsing_flags,
                                      PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
                                                PRS_FLAG_OVERETH_IPV6) ?
                                SKB_GSO_TCPV6 : SKB_GSO_TCPV4;
        }
Quoted 4 lines

I see it sets gso_type but apparently only if mode is GRO? Will this still break if mode is set to LRO?

In net-next tree, line 464 looks like :

static void bnx2x_set_gro_params(struct sk_buff *skb, u16 parsing_flags,
u16 len_on_bd, unsigned int pkt_len)

{
        /* TPA aggregation won't have either IP options or TCP options
         * other than timestamp or IPv6 extension headers.
         */
        u16 hdrs_len = ETH_HLEN + sizeof(struct tcphdr);

        if (GET_FLAG(parsing_flags, PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
            PRS_FLAG_OVERETH_IPV6) {
                hdrs_len += sizeof(struct ipv6hdr);
<HERE>          skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
        } else {
                hdrs_len += sizeof(struct iphdr);
<HERE>          skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
        }

        /* Check if there was a TCP timestamp, if there is it's will
         * always be 12 bytes length: nop nop kind length echo val.
         *
         * Otherwise FW would close the aggregation.
         */
        if (parsing_flags & PARSING_FLAGS_TIME_STAMP_EXIST_FLAG)
                hdrs_len += TPA_TSTAMP_OPT_LEN;

        skb_shinfo(skb)->gso_size = len_on_bd - hdrs_len;
Quoted 2 lines

...

OK, it looks like intel/qlogic can just look at skb protocol and set gso_type to TCPV4/V6.
I'll try it and see if this works.

Signature · 1 line
MST
#7 lore raw
In reply to Eric Dumazet
Quoted 66 lines · Eric Dumazet
Quoted 31 lines · Michael S. Tsirkin
Quoted 7 lines · Eric Dumazet
Quoted 5 lines · Michael S. Tsirkin

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

Quoted 5 lines
Quoted 3 lines

I see 3 in-tree drivers that do this:

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c: skb_shinfo(skb)->gso_size = bnx2x

bnx2x is fine, take a look at lines 464

Is this what you mean?

        /* This is needed in order to enable forwarding support */
        if (frag_size) {
                skb_shinfo(skb)->gso_size = bnx2x_set_lro_mss(bp,
                                        tpa_info->parsing_flags, len_on_bd);

                /* set for GRO */
                if (fp->mode == TPA_MODE_GRO)
                        skb_shinfo(skb)->gso_type =
                            (GET_FLAG(tpa_info->parsing_flags,
                                      PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
                                                PRS_FLAG_OVERETH_IPV6) ?
                                SKB_GSO_TCPV6 : SKB_GSO_TCPV4;
        }
Quoted 4 lines

I see it sets gso_type but apparently only if mode is GRO? Will this still break if mode is set to LRO?

In net-next tree, line 464 looks like :

static void bnx2x_set_gro_params(struct sk_buff *skb, u16 parsing_flags,
u16 len_on_bd, unsigned int pkt_len)

{
        /* TPA aggregation won't have either IP options or TCP options
         * other than timestamp or IPv6 extension headers.
         */
        u16 hdrs_len = ETH_HLEN + sizeof(struct tcphdr);

        if (GET_FLAG(parsing_flags, PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) ==
            PRS_FLAG_OVERETH_IPV6) {
                hdrs_len += sizeof(struct ipv6hdr);
<HERE>          skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
        } else {
                hdrs_len += sizeof(struct iphdr);
<HERE>          skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
        }

        /* Check if there was a TCP timestamp, if there is it's will
         * always be 12 bytes length: nop nop kind length echo val.
         *
         * Otherwise FW would close the aggregation.
         */
        if (parsing_flags & PARSING_FLAGS_TIME_STAMP_EXIST_FLAG)
                hdrs_len += TPA_TSTAMP_OPT_LEN;

        skb_shinfo(skb)->gso_size = len_on_bd - hdrs_len;
Quoted 1 line

...

OK this means cbf1de72324a8105ddcc3d9ce9acbc613faea17e might be needed in 3.8 and maybe -stable, otherwise macvtap crashes when LRO is set.

Signature · 1 line
MST
#8 lore raw
Quoted 4 lines · Michael S. Tsirkin

OK this means cbf1de72324a8105ddcc3d9ce9acbc613faea17e might be needed in 3.8 and maybe -stable, otherwise macvtap crashes when LRO is set.

You may be right : My issue was an accounting error in a rarely used path (qdisc on ingress). Yours is definitely more serious ;)

#9 lore raw
In reply to Michael S. Tsirkin
Quoted 3 lines · Michael S. Tsirkin

I see it sets gso_type but apparently only if mode is GRO? Will this still break if mode is set to LRO?

The comment inside skb_warn_if_lro() said:

/* LRO sets gso_size but not gso_type, whereas if GSO is really
* wanted then gso_type will be set. */

#10 lore raw
In reply to Michael S. Tsirkin
Quoted 3 lines · Michael S. Tsirkin

Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

I fail to see where net core could do that.

These drivers kind of bypass GRO, so they must provide skbs that are 100% correct.

#11 lore raw
In reply to Michael S. Tsirkin
Quoted 39 lines · Michael S. Tsirkin
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 8 lines
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

Quoted 6 lines

Hmm, ixgbe_get_headlen isn't run on linear skbs though.

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

[...]

It should be set to the segment size on the wire, so TCP gets a correct picture of packet loss. The networking core has no idea what hardware/ firmware LRO did.

I've previously raised this issue of macvlan vs LRO (which is the same issue we previously had with IP forwarding and with bridging):

     http://thread.gmane.org/gmane.linux.network/221695

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#12 lore raw
Quoted 52 lines · Ben Hutchings
Quoted 39 lines · Michael S. Tsirkin
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 8 lines
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

Quoted 6 lines

Hmm, ixgbe_get_headlen isn't run on linear skbs though.

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

[...]

It should be set to the segment size on the wire, so TCP gets a correct picture of packet loss. The networking core has no idea what hardware/ firmware LRO did.

Quoted 5 lines

I've previously raised this issue of macvlan vs LRO (which is the same issue we previously had with IP forwarding and with bridging):

     http://thread.gmane.org/gmane.linux.network/221695

Ben.

I see, you proposed disabling LRO the moment a macvlan is attached. If I understand correctly, the difference as compared to bridge is that bridge normally consumes all incoming packets, macvlan is often used in parallel with the underlying interface.

BTW are there other issues with forwarding/bridging and LRO? If everyone sets gso_type in packets it seems we can leave LRO set even with bridging?

Quoted 4 lines
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#13 lore raw
Quoted 57 lines · Michael S. Tsirkin
Quoted 56 lines · Ben Hutchings
Quoted 39 lines · Michael S. Tsirkin
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 8 lines
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

Quoted 6 lines

Hmm, ixgbe_get_headlen isn't run on linear skbs though.

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

[...]

It should be set to the segment size on the wire, so TCP gets a correct picture of packet loss. The networking core has no idea what hardware/ firmware LRO did.

I've previously raised this issue of macvlan vs LRO (which is the same issue we previously had with IP forwarding and with bridging):

     http://thread.gmane.org/gmane.linux.network/221695
Quoted 6 lines
Quoted 1 line

Ben.

I see, you proposed disabling LRO the moment a macvlan is attached. If I understand correctly, the difference as compared to bridge is that bridge normally consumes all incoming packets, macvlan is often used in parallel with the underlying interface.

Not so different from IP forwarding, though, in that a single interface can both forward packets and deliver them locally.

Quoted 3 lines

BTW are there other issues with forwarding/bridging and LRO? If everyone sets gso_type in packets it seems we can leave LRO set even with bridging?

Some implementations of LRO violate the end-to-end principle by merging segments with varying lengths and TCP timestamps. GRO is very careful to ensure that the original packets can be recovered from the skbs it produces.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#14 lore raw
Quoted 60 lines · Ben Hutchings
Quoted 59 lines · Michael S. Tsirkin
Quoted 57 lines · Ben Hutchings
Quoted 39 lines · Michael S. Tsirkin
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 8 lines
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

Quoted 6 lines

Hmm, ixgbe_get_headlen isn't run on linear skbs though.

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

[...]

It should be set to the segment size on the wire, so TCP gets a correct picture of packet loss. The networking core has no idea what hardware/ firmware LRO did.

I've previously raised this issue of macvlan vs LRO (which is the same issue we previously had with IP forwarding and with bridging):

     http://thread.gmane.org/gmane.linux.network/221695

Ben.

Quoted 7 lines
Quoted 4 lines

I see, you proposed disabling LRO the moment a macvlan is attached. If I understand correctly, the difference as compared to bridge is that bridge normally consumes all incoming packets, macvlan is often used in parallel with the underlying interface.

Not so different from IP forwarding, though, in that a single interface can both forward packets and deliver them locally.

Hmm, for ip forwarding we don't try do disable LRO on the device, do we? What's the solution there?

Quoted 15 lines
Quoted 3 lines

BTW are there other issues with forwarding/bridging and LRO? If everyone sets gso_type in packets it seems we can leave LRO set even with bridging?

Some implementations of LRO violate the end-to-end principle by merging segments with varying lengths and TCP timestamps. GRO is very careful to ensure that the original packets can be recovered from the skbs it produces.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#15 lore raw
Quoted 66 lines · Michael S. Tsirkin
Quoted 65 lines · Ben Hutchings
Quoted 63 lines · Michael S. Tsirkin
Quoted 52 lines · Ben Hutchings
Quoted 39 lines · Michael S. Tsirkin
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Michael S. Tsirkin

It seems that starting with kernel 3.3 ixgbe sets gso_size for incoming frames. It seems that this might result in gso_size being set even when gso_type is 0.
This in turn leads to a crash at macvtap_skb_to_vnet_hdr drivers/net/macvtap.c:628
which has this code:

       if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);

                /* This is a hint as to how much should be linear. */
                vnet_hdr->hdr_len = skb_headlen(skb);
                vnet_hdr->gso_size = sinfo->gso_size;
                if (sinfo->gso_type & SKB_GSO_TCPV4)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                else if (sinfo->gso_type & SKB_GSO_TCPV6)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                else if (sinfo->gso_type & SKB_GSO_UDP)
                        vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
                else
                        BUG();
                if (sinfo->gso_type & SKB_GSO_TCP_ECN)
                        vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
        } else
                vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
Quoted 8 lines
Quoted 5 lines

Since skb_is_gso tests gso_size.

What's the right way to handle this? Should skb_is_gso be changed to test gso_type != 0?

Or fix ixgbe to set gso_type in ixgbe_get_headlen(), as it does all the dissection.

Quoted 6 lines

Hmm, ixgbe_get_headlen isn't run on linear skbs though.

Also, I'm not sure I understand when should drivers set gso size for incoming messages and what is a reasonable value. Commit log talks about improved performance for lossy connections, in this case, isn't this something net core should set?

[...]

It should be set to the segment size on the wire, so TCP gets a correct picture of packet loss. The networking core has no idea what hardware/ firmware LRO did.

Quoted 5 lines

I've previously raised this issue of macvlan vs LRO (which is the same issue we previously had with IP forwarding and with bridging):

     http://thread.gmane.org/gmane.linux.network/221695

Ben.

I see, you proposed disabling LRO the moment a macvlan is attached. If I understand correctly, the difference as compared to bridge is that bridge normally consumes all incoming packets, macvlan is often used in parallel with the underlying interface.

Quoted 5 lines
Quoted 2 lines

Not so different from IP forwarding, though, in that a single interface can both forward packets and deliver them locally.

Hmm, for ip forwarding we don't try do disable LRO on the device, do we? What's the solution there?

Yes we do (or we did).

Ben.

Quoted 15 lines
Quoted 15 lines
Quoted 3 lines

BTW are there other issues with forwarding/bridging and LRO? If everyone sets gso_type in packets it seems we can leave LRO set even with bridging?

Some implementations of LRO violate the end-to-end principle by merging segments with varying lengths and TCP timestamps. GRO is very careful to ensure that the original packets can be recovered from the skbs it produces.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.