} else if (Ip::Qos::TheConfig.tosParentHit && hierCode==PARENT_HIT) {
tos = Ip::Qos::TheConfig.tosParentHit;
debugs(33, 2, "QOS: Parent Peer hit with hier code=" << hierCode << ", TOS=" << int(tos));
- } else if (Ip::Qos::TheConfig.tosMiss) {
- tos = Ip::Qos::TheConfig.tosMiss;
- debugs(33, 2, "QOS: Cache miss, setting TOS=" << int(tos));
- } else if (Ip::Qos::TheConfig.preserveMissTos && Ip::Qos::TheConfig.preserveMissTosMask) {
+ } else if (Ip::Qos::TheConfig.preserveMissTos) {
tos = fd_table[conn->fd].tosFromServer & Ip::Qos::TheConfig.preserveMissTosMask;
+ tos = (tos & ~Ip::Qos::TheConfig.tosMissMask) | (Ip::Qos::TheConfig.tosMiss & Ip::Qos::TheConfig.tosMissMask);
debugs(33, 2, "QOS: Preserving TOS on miss, TOS=" << int(tos));
+ } else if (Ip::Qos::TheConfig.tosMiss) {
+ tos = Ip::Qos::TheConfig.tosMiss & Ip::Qos::TheConfig.tosMissMask;
+ debugs(33, 2, "QOS: Cache miss, setting TOS=" << int(tos));
}
return setSockTos(conn, tos);
}
} else if (Ip::Qos::TheConfig.markParentHit && hierCode==PARENT_HIT) {
mark = Ip::Qos::TheConfig.markParentHit;
debugs(33, 2, "QOS: Parent Peer hit with hier code=" << hierCode << ", Mark=" << mark);
- } else if (Ip::Qos::TheConfig.markMiss) {
- mark = Ip::Qos::TheConfig.markMiss;
- debugs(33, 2, "QOS: Cache miss, setting Mark=" << mark);
} else if (Ip::Qos::TheConfig.preserveMissMark) {
mark = fd_table[conn->fd].nfmarkFromServer & Ip::Qos::TheConfig.preserveMissMarkMask;
+ mark = (mark & ~Ip::Qos::TheConfig.markMissMask) | (Ip::Qos::TheConfig.markMiss & Ip::Qos::TheConfig.markMissMask);
debugs(33, 2, "QOS: Preserving mark on miss, Mark=" << mark);
+ } else if (Ip::Qos::TheConfig.markMiss) {
+ mark = Ip::Qos::TheConfig.markMiss & Ip::Qos::TheConfig.markMissMask;
+ debugs(33, 2, "QOS: Cache miss, setting Mark=" << mark);
}
return setSockNfmark(conn, mark);
}
tosSiblingHit = 0;
tosParentHit = 0;
tosMiss = 0;
+ tosMissMask = 0;
preserveMissTos = false;
preserveMissTosMask = 0xFF;
markLocalHit = 0;
markSiblingHit = 0;
markParentHit = 0;
markMiss = 0;
+ markMissMask = 0;
preserveMissMark = false;
preserveMissMarkMask = 0xFFFFFFFF;
}
} else if (strncmp(token, "miss=",5) == 0) {
+ char *end;
if (mark) {
- if (!xstrtoui(&token[5], NULL, &markMiss, 0, std::numeric_limits<nfmark_t>::max())) {
+ if (!xstrtoui(&token[5], &end, &markMiss, 0, std::numeric_limits<nfmark_t>::max())) {
debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss value " << &token[5]);
self_destruct();
}
+ if (*end == '/') {
+ if (!xstrtoui(end + 1, NULL, &markMissMask, 0, std::numeric_limits<nfmark_t>::max())) {
+ debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss mask value " << (end + 1) << ". Using 0xFFFFFFFF instead.");
+ markMissMask = 0xFFFFFFFF;
+ }
+ } else {
+ markMissMask = 0xFFFFFFFF;
+ }
} else {
unsigned int v = 0;
- if (!xstrtoui(&token[5], NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
+ if (!xstrtoui(&token[5], &end, &v, 0, std::numeric_limits<tos_t>::max())) {
debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss value " << &token[5]);
self_destruct();
}
tosMiss = (tos_t)v;
+ if (*end == '/') {
+ if (!xstrtoui(end + 1, NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
+ debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss mask value " << (end + 1) << ". Using 0xFF instead.");
+ tosMissMask = 0xFF;
+ } else
+ tosMissMask = (tos_t)v;
+ } else {
+ tosMissMask = 0xFF;
+ }
}
} else if (strcmp(token, "disable-preserve-miss") == 0) {
}
if (tosMiss > 0) {
p += snprintf(p, 11, " miss=0x%02X", tosMiss);
+ if (tosMissMask!=0xFFU) {
+ p += snprintf(p, 6, "/0x%02X", markMissMask);
+ }
}
if (preserveMissTos == 0) {
p += snprintf(p, 23, " disable-preserve-miss");
}
if (markMiss > 0) {
p += snprintf(p, 17, " miss=0x%02X", markMiss);
+ if (markMissMask!=0xFFFFFFFFU) {
+ p += snprintf(p, 12, "/0x%02X", markMissMask);
+ }
}
if (preserveMissMark == false) {
p += snprintf(p, 23, " disable-preserve-miss");
tos_t tosSiblingHit; ///< TOS value to apply to hits from siblings
tos_t tosParentHit; ///< TOS value to apply to hits from parent
tos_t tosMiss; ///< TOS value to apply to cache misses
+ tos_t tosMissMask; ///< Mask for TOS value to apply to cache misses. Applied to the tosMiss value.
bool preserveMissTos; ///< Whether to preserve the TOS value of the inbound packet for misses
- tos_t preserveMissTosMask; ///< The mask to apply when preserving the TOS of misses
+ tos_t preserveMissTosMask; ///< The mask to apply when preserving the TOS of misses. Applies to preserved value from upstream.
nfmark_t markLocalHit; ///< Netfilter mark value to apply to local cache hits
nfmark_t markSiblingHit; ///< Netfilter mark value to apply to hits from siblings
nfmark_t markParentHit; ///< Netfilter mark value to apply to hits from parent
nfmark_t markMiss; ///< Netfilter mark value to apply to cache misses
+ nfmark_t markMissMask; ///< Mask for netfilter mark value to apply to cache misses. Applied to the markMiss value.
bool preserveMissMark; ///< Whether to preserve netfilter mark value of inbound connection
- nfmark_t preserveMissMarkMask; ///< The mask to apply when preserving the netfilter mark of misses
+ nfmark_t preserveMissMarkMask; ///< The mask to apply when preserving the netfilter mark of misses. Applied to preserved value from upstream.
acl_tos *tosToServer; ///< The TOS that packets to the web server should be marked with, based on ACL
acl_tos *tosToClient; ///< The TOS that packets to the client should be marked with, based on ACL