Revision: 1946
http://undernet-ircu.svn.sourceforge.net/undernet-ircu/?rev=1946&view=rev
Author: entrope
Date: 2010-03-09 03:05:38 +0000 (Tue, 09 Mar 2010)
Log Message:
-----------
Clarify the link rejection message for unauthorized hubs.
Make the function that makes that decision a little more maintainable.
Modified Paths:
--------------
ircu2/branches/u2_10_12_branch/ChangeLog
ircu2/branches/u2_10_12_branch/ircd/m_server.c
Modified: ircu2/branches/u2_10_12_branch/ChangeLog
===================================================================
--- ircu2/branches/u2_10_12_branch/ChangeLog 2010-03-09 02:59:32 UTC (rev
1945)
+++ ircu2/branches/u2_10_12_branch/ChangeLog 2010-03-09 03:05:38 UTC (rev
1946)
@@ -1,5 +1,13 @@
2010-03-08 Michael Poole <[email protected]>
+ * ircd/m_server.c (enum lh_type): New type.
+ (check_loop_and_lh): Use the enum instead of magic integers.
+ Make the error message a little clearer when neither "hub" nor
+ "maxhops" is specified for a server. Clean up the control flow
+ when we decide to reject the link.
+
+2010-03-08 Michael Poole <[email protected]>
+
* ircd/test/ircd_match_t.c (_SC_PAGE_SIZE): Default to
_SC_PAGESIZE if that is defined (as it is on some Unixes).
Modified: ircu2/branches/u2_10_12_branch/ircd/m_server.c
===================================================================
--- ircu2/branches/u2_10_12_branch/ircd/m_server.c 2010-03-09 02:59:32 UTC
(rev 1945)
+++ ircu2/branches/u2_10_12_branch/ircd/m_server.c 2010-03-09 03:05:38 UTC
(rev 1946)
@@ -96,6 +96,14 @@
return prot;
}
+/** Reason not to accept a server's new announcement. */
+enum lh_type {
+ ALLOWED, /**< The new server link is accepted. */
+ MAX_HOPS_EXCEEDED, /**< The path to the server is too long. */
+ NOT_ALLOWED_TO_HUB, /**< My peer is not allowed to hub for the server. */
+ I_AM_NOT_HUB /**< I have another active server link but not FEAT_HUB. */
+};
+
/** Check whether the introduction of a new server would cause a loop
* or be disallowed by leaf and hub configuration directives.
* @param[in] cptr Neighbor who sent the message.
@@ -115,7 +123,8 @@
struct Client* acptr;
struct Client* LHcptr = NULL;
struct ConfItem* lhconf;
- int active_lh_line = 0, ii;
+ enum lh_type active_lh_line = ALLOWED;
+ int ii;
if (ghost)
*ghost = 0;
@@ -130,18 +139,22 @@
if (!feature_bool(FEAT_HUB))
for (ii = 0; ii <= HighestFd; ii++)
if (LocalClientArray[ii] && IsServer(LocalClientArray[ii])) {
- active_lh_line = 3;
+ active_lh_line = I_AM_NOT_HUB;
break;
}
}
else if (hop > lhconf->maximum)
{
- active_lh_line = 1;
+ /* Because "maximum" should be 0 for non-hub links, check whether
+ * there is a hub mask -- if not, complain that the server isn't
+ * allowed to hub.
+ */
+ active_lh_line = lhconf->hub_limit ? MAX_HOPS_EXCEEDED :
NOT_ALLOWED_TO_HUB;
}
else if (lhconf->hub_limit && match(lhconf->hub_limit, host))
{
struct Client *ac3ptr;
- active_lh_line = 2;
+ active_lh_line = NOT_ALLOWED_TO_HUB;
if (junction)
for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up)
if (IsJunction(ac3ptr)) {
@@ -192,7 +205,7 @@
*/
if (IsConnecting(acptr))
{
- if (!active_lh_line && exit_client(cptr, acptr, &me,
+ if (active_lh_line == ALLOWED && exit_client(cptr, acptr, &me,
"Just connected via another link") == CPTR_KILLED)
return CPTR_KILLED;
/*
@@ -319,7 +332,7 @@
else if (cli_from(c2ptr) == cptr || IsServer(sptr))
{
struct Client *killedptrfrom = cli_from(c2ptr);
- if (active_lh_line)
+ if (active_lh_line != ALLOWED)
{
/*
* If the L: or H: line also gets rid of this link,
@@ -332,7 +345,7 @@
* line problem, we don't squit that.
*/
if (cli_from(c2ptr) == cptr || (LHcptr && a_kills_b_too(c2ptr,
LHcptr)))
- active_lh_line = 0;
+ active_lh_line = ALLOWED;
else
{
/*
@@ -369,12 +382,12 @@
}
else
{
- if (active_lh_line)
+ if (active_lh_line != ALLOWED)
{
if (LHcptr && a_kills_b_too(LHcptr, acptr))
break;
if (cli_from(acptr) == cptr || (LHcptr && a_kills_b_too(acptr,
LHcptr)))
- active_lh_line = 0;
+ active_lh_line = ALLOWED;
else
{
LHcptr = 0;
@@ -397,35 +410,27 @@
}
}
- if (active_lh_line)
+ if (active_lh_line != ALLOWED)
{
- int killed = 0;
- if (LHcptr)
- killed = a_kills_b_too(LHcptr, sptr);
- else
+ if (!LHcptr)
LHcptr = sptr;
- if (active_lh_line == 1)
+ if (active_lh_line == MAX_HOPS_EXCEEDED)
{
- if (exit_client_msg(cptr, LHcptr, &me,
- "Maximum hops exceeded for %s at %s",
- cli_name(cptr), host) == CPTR_KILLED)
- return CPTR_KILLED;
+ return exit_client_msg(cptr, LHcptr, &me,
+ "Maximum hops exceeded for %s at %s",
+ cli_name(cptr), host);
}
- else if (active_lh_line == 2)
+ else if (active_lh_line == NOT_ALLOWED_TO_HUB)
{
- if (exit_client_msg(cptr, LHcptr, &me,
- "%s is not allowed to hub for %s",
- cli_name(cptr), host) == CPTR_KILLED)
- return CPTR_KILLED;
+ return exit_client_msg(cptr, LHcptr, &me,
+ "%s is not allowed to hub for %s",
+ cli_name(cptr), host);
}
- else
+ else /* I_AM_NOT_HUB */
{
ServerStats->is_ref++;
- if (exit_client(cptr, LHcptr, &me, "I'm a leaf, define HUB") ==
CPTR_KILLED)
- return CPTR_KILLED;
+ return exit_client(cptr, LHcptr, &me, "I'm a leaf, define HUB");
}
- /* We just squit somebody, and it wasn't cptr. */
- return 0;
}
return 1;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches