Page MenuHomeFreeBSD

tcp: restrict flowtype copying to specific RSS TCP types
ClosedPublic

Authored by cc on Mon, Feb 9, 5:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Feb 12, 11:40 AM
Unknown Object (File)
Wed, Feb 11, 4:54 PM
Unknown Object (File)
Wed, Feb 11, 4:17 AM
Unknown Object (File)
Tue, Feb 10, 11:55 PM
Unknown Object (File)
Tue, Feb 10, 10:15 PM
Unknown Object (File)
Tue, Feb 10, 8:24 PM
Unknown Object (File)
Tue, Feb 10, 1:55 PM
Unknown Object (File)
Tue, Feb 10, 11:23 AM

Details

Summary

Recent driver fixes like "20285cad7a55", "efcc0423d80e" and "21dd554d1697" reveal that the m_pkthdr.rsstype shall be more strictly checked before accepting RSS values for inp_flowid.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

cc requested review of this revision.Mon, Feb 9, 5:11 PM

Slightly worried some NIC somwhere might not be setting this when it should. Is this solving a problem for you?

cc retitled this revision from tcp_syncache: Restrict flowtype copying to specific RSS TCP types to tcp: restrict flowtype copying to specific RSS TCP types.Mon, Feb 9, 5:19 PM
cc edited the summary of this revision. (Show Details)

Slightly worried some NIC somwhere might not be setting this when it should. Is this solving a problem for you?

The "Test Plan" section from https://reviews.freebsd.org/D55137 shows that M_HASHTYPE_OPAQUE pseudo-hash values can be accepted, in contrast.

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

If we have some rules regarding how to set the hash type, can we document them somewhere? This way driver writers know what to do and we can inspect drivers and fix them.

If we have some rules regarding how to set the hash type, can we document them somewhere? This way driver writers know what to do and we can inspect drivers and fix them.

I'm basing it off https://cgit.freebsd.org/src/tree/sys/sys/mbuf.h#n527

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

I think it's OK to have pseudo hash, e.g. if_vtnet.c, for the driver's own purpose (like "ordering"). But it is incorrect for TCP, as inp_flowid in TCP should be a 4-tuple hash value.

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

Thinking about this more, I think when we are using the hash for setting flowtype, we should check for valid toeplitz hash types, since we're counting on being able to calculate the same hash in software. So I think this patch is probably the correct place to fix this. I think it would be shorter/cleaner to use M_HASHTYPE_ISHASH(). See https://reviews.freebsd.org/D52989

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

Thinking about this more, I think when we are using the hash for setting flowtype, we should check for valid toeplitz hash types, since we're counting on being able to calculate the same hash in software. So I think this patch is probably the correct place to fix this. I think it would be shorter/cleaner to use M_HASHTYPE_ISHASH(). See https://reviews.freebsd.org/D52989

Ok.

Separately, this was noticed because some of the drivers are setting opaque when there is no hash value, I think all the intel drivers have this behavior and only a couple have been patched. The intel docs are pretty clear that they implement the Microsoft hashing or it will be empty. I think there might be a few other drivers with similar issue(s).

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

Thinking about this more, I think when we are using the hash for setting flowtype, we should check for valid toeplitz hash types, since we're counting on being able to calculate the same hash in software. So I think this patch is probably the correct place to fix this. I think it would be shorter/cleaner to use M_HASHTYPE_ISHASH(). See https://reviews.freebsd.org/D52989

Question: Is M_HASHTYPE_RSS_IPV4 or M_HASHTYPE_RSS_IPV6 (a hash only on the src/dst address) acceptable or not? M_HASHTYPE_ISHASH() is true for them.

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

Thinking about this more, I think when we are using the hash for setting flowtype, we should check for valid toeplitz hash types, since we're counting on being able to calculate the same hash in software. So I think this patch is probably the correct place to fix this. I think it would be shorter/cleaner to use M_HASHTYPE_ISHASH(). See https://reviews.freebsd.org/D52989

Question: Is M_HASHTYPE_RSS_IPV4 or M_HASHTYPE_RSS_IPV6 (a hash only on the src/dst address) acceptable or not? M_HASHTYPE_ISHASH() is true for them.

It should never happen. But to be safe, maybe make a new M_HASHTYPE_ISHASH_TCP ? At this point, my only objection is to the ugly comparisons :)

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

Thinking about this more, I think when we are using the hash for setting flowtype, we should check for valid toeplitz hash types, since we're counting on being able to calculate the same hash in software. So I think this patch is probably the correct place to fix this. I think it would be shorter/cleaner to use M_HASHTYPE_ISHASH(). See https://reviews.freebsd.org/D52989

Question: Is M_HASHTYPE_RSS_IPV4 or M_HASHTYPE_RSS_IPV6 (a hash only on the src/dst address) acceptable or not? M_HASHTYPE_ISHASH() is true for them.

It should never happen. But to be safe, maybe make a new M_HASHTYPE_ISHASH_TCP ? At this point, my only objection is to the ugly comparisons :)

I totally agree. If we want such a hash, we should check for it.

I think it's driver bugs that have flown under the radar until the recent RSS change so I'm not sure this is the place to do this.

In particular to this review, opaque and opaque_hash should both be usable hashes if they are implemented correctly in the driver.

Thinking about this more, I think when we are using the hash for setting flowtype, we should check for valid toeplitz hash types, since we're counting on being able to calculate the same hash in software. So I think this patch is probably the correct place to fix this. I think it would be shorter/cleaner to use M_HASHTYPE_ISHASH(). See https://reviews.freebsd.org/D52989

Question: Is M_HASHTYPE_RSS_IPV4 or M_HASHTYPE_RSS_IPV6 (a hash only on the src/dst address) acceptable or not? M_HASHTYPE_ISHASH() is true for them.

It should never happen. But to be safe, maybe make a new M_HASHTYPE_ISHASH_TCP ? At this point, my only objection is to the ugly comparisons :)

I totally agree. If we want such a hash, we should check for it.

Looks like a common ground here :) I will work on the idea M_HASHTYPE_ISHASH_TCP. thanks

  1. cancel the unnecessary change to sc_flowtype check in syncache_socket()
  2. for the rest, check RSS types by a new macro M_HASHTYPE_ISHASH_TCP
This revision is now accepted and ready to land.Tue, Feb 10, 7:32 AM