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