You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2025/01/13 20:07:47 UTC
[PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
cmcfarlen opened a new pull request, #11951:
URL: https://github.com/apache/trafficserver/pull/11951
This PR adds some tests for remap rule parsing and fixes a potential crasher when multiple `.definefilter` lines use the same filter name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #11951:
URL: https://github.com/apache/trafficserver/pull/11951#discussion_r1915451697
##########
src/proxy/http/remap/RemapConfig.cc:
##########
@@ -100,6 +97,14 @@ BUILD_TABLE_INFO::BUILD_TABLE_INFO()
BUILD_TABLE_INFO::~BUILD_TABLE_INFO()
{
this->reset();
+
+ // clean up any leftover named filter rules
+ auto *rp = rules_list;
+ while (rp != nullptr) {
+ auto *tmp = rp->next;
+ delete rp;
+ rp = tmp;
+ }
Review Comment:
They aren't actually shared, but copied into the actual mappings as they are created. This code is very pointer-heavy and is over due for a general update to C++ pass. I do plan on expanding this work soon, but wanted to get these couple fixes that will need to be back ported. Thanks for the review!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on code in PR #11951:
URL: https://github.com/apache/trafficserver/pull/11951#discussion_r1915205598
##########
src/proxy/http/remap/RemapConfig.cc:
##########
@@ -100,6 +97,14 @@ BUILD_TABLE_INFO::BUILD_TABLE_INFO()
BUILD_TABLE_INFO::~BUILD_TABLE_INFO()
{
this->reset();
+
+ // clean up any leftover named filter rules
+ auto *rp = rules_list;
+ while (rp != nullptr) {
+ auto *tmp = rp->next;
+ delete rp;
+ rp = tmp;
+ }
Review Comment:
Awesome.
Let's not do this in this PR because what you're doing here with delete appropriately fits the current setup, but it would be good to change these over to shared_ptrs. (I think they are shared across rules so unique_ptr won't work?).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen merged PR #11951:
URL: https://github.com/apache/trafficserver/pull/11951
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on PR #11951:
URL: https://github.com/apache/trafficserver/pull/11951#issuecomment-2590140449
Turns out these tests found a legit memory leak
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #11951:
URL: https://github.com/apache/trafficserver/pull/11951#discussion_r1913749763
##########
src/proxy/http/remap/RemapConfig.cc:
##########
@@ -146,6 +143,15 @@ process_filter_opt(url_mapping *mp, const BUILD_TABLE_INFO *bti, char *errStrBuf
bti->behavior_policy)) != nullptr) {
break;
}
+ if (auto rule = *rpp; rule) {
+ // If no IP addresses are listed, treat that like `@src_ip=all`.
+ if (rule->src_ip_valid == 0 && rule->src_ip_cnt == 0) {
+ src_ip_info_t *ipi = &rule->src_ip_array[rule->src_ip_cnt];
+ ipi->match_all_addresses = true;
+ rule->src_ip_cnt++;
+ rule->src_ip_valid = 1;
+ }
+ }
Review Comment:
Moved this logic to when the filter rules are merged during a map declaration. This avoids the need to check if a src_ip was already added since this happens outside of filter definition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add unit tests for remap rules. Fix release-assert crasher [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #11951:
URL: https://github.com/apache/trafficserver/pull/11951#discussion_r1913748373
##########
include/proxy/http/remap/RemapConfig.h:
##########
@@ -76,6 +76,7 @@ struct BUILD_TABLE_INFO {
};
const char *remap_parse_directive(BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize);
+bool remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti);
Review Comment:
This declaration moved out of anonymous namespace so it can be tested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org