Hii I have added all the default flags in port_cfg_new(). But I can't see as to why I need to update port_parse_config() and connection_listener_new() as they seem to work very well and are encapsulated from port_cfg_new() (Please correct me if I go wrong). The default flags and their values are as follows -->
So the problem with port_parse_config() is that the all of its defaults would have to be kept in sync with port_cfg_new(). If we make a change to one place, we have to make it to the other, or else we don't get the expected results. This has caused hard-to-diagnose bugs in the past.
A good solution here might be to create the port_cfg_t object near the start of the loop in port_cfg_t, and then assign to its flags directly, rather than first assigning them to intermediate variables and only copying them at the end of the loop. Teor might have some thoughts here as the original opener of this bug.
As for port_cfg_new(): it isn't actually necessary to set any flags to 0 there, since the object is allocated with tor_malloc_zero(), which initializes all the memory in it to 0.
A good solution here might be to create the port_cfg_t object near the start of the loop in port_cfg_t, and then assign to its flags directly, rather than first assigning them to intermediate variables and only copying them at the end of the loop. Teor might have some thoughts here as the original opener of this bug.
Yes, I think we should create a port_config_t object using port_config_new() at the start of:
port_parse_config()
connection_listener_new()
And then make any changes we need to make in that object.
Please let us know if you find any differences between the default flags in port_config_new() and port_parse_config().
When you update port_parse_config() to use port_cfg_new(), all the defaults will come from the same place.
So I am not sure what we should do with the extra settings in connection_listener_new() at line 1517. I think we should delete them (stop forcing them on). But that's not a simple refactor, and it needs to happen in two different releases. So I opened #33607 (moved) and #33608 (moved) for that change.
(This function is a bit confusing, because it's very big. Over time, we want to split big functions into smaller functions, so they are easier to understand. But we don't need to do that in this pull request.)
A nice follow up patch to this would be to change some of the integer values that we use with only zero and ones to be C99 bool's instead of integers :-)