@@ -381,14 +381,14 @@ func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref ga
381381// ref: https://github.com/Kong/kubernetes-ingress-controller/blob/57472721319e2c63e56cb8540425257e8e02520f/internal/dataplane/translator/subtranslator/httproute_atc.go#L279-L296
382382func calculateHTTPRoutePriority (match * gatewayv1.HTTPRouteMatch , ruleIndex int , hosts []string ) uint64 {
383383 const (
384- // PreciseHostnameShiftBits assigns bit 43-50 for the length of hostname(max length=253).
385- PreciseHostnameShiftBits = 43
386- // HostnameLengthShiftBits assigns bits 35-42 for the length of hostname(max length=253).
387- HostnameLengthShiftBits = 35
388- // ExactPathShiftBits assigns bit 34 to mark if the match is exact path match .
389- ExactPathShiftBits = 34
390- // PathLengthShiftBits assigns bits 23-32 to path length. (max length = 1024, but must start with /)
391- PathLengthShiftBits = 23
384+ // PreciseHostnameShiftBits assigns bit 31-38 for the length of hostname(max length=253).
385+ // which has 8 bits, so the max length of hostname is 2^8-1 = 255.
386+ PreciseHostnameShiftBits = 31
387+
388+ // HostnameLengthShiftBits assigns bits 23-30 for the length of hostname(max length=253) .
389+ // which has 8 bits, so the max length of hostname is 2^8-1 = 255.
390+ HostnameLengthShiftBits = 23
391+
392392 // MethodMatchShiftBits assigns bit 22 to mark if method is specified.
393393 MethodMatchShiftBits = 22
394394 // HeaderNumberShiftBits assign bits 17-21 to number of headers. (max number of headers = 16)
@@ -429,20 +429,6 @@ func calculateHTTPRoutePriority(match *gatewayv1.HTTPRouteMatch, ruleIndex int,
429429 priority |= (uint64 (maxHostnameLength ) << HostnameLengthShiftBits )
430430 }
431431
432- // ExactPathShiftBits
433- if match .Path != nil && match .Path .Type != nil && * match .Path .Type == gatewayv1 .PathMatchExact {
434- priority |= (1 << ExactPathShiftBits )
435- }
436-
437- // PathLengthShiftBits
438- // max length of path is 1024, but path must start with /, so we use PathLength-1 to fill the bits.
439- if match .Path != nil && match .Path .Value != nil {
440- pathLength := len (* match .Path .Value )
441- if pathLength > 0 {
442- priority |= (uint64 (pathLength - 1 ) << PathLengthShiftBits )
443- }
444- }
445-
446432 // MethodMatchShiftBits
447433 if match .Method != nil {
448434 priority |= (1 << MethodMatchShiftBits )
0 commit comments