Skip to content
Snippets Groups Projects
Commit 98a0e329 authored by Eric Barton's avatar Eric Barton
Browse files

* Stopped outputting error messages on lctl set_route, when <nid> isn't

    know.  This was a no-op, now it's a silent no-op.

*   Fixed help string in lctl.

*   Fixed lctl set_route date+time parsing bug.
parent 82e17774
No related branches found
No related tags found
No related merge requests found
...@@ -162,9 +162,12 @@ kportal_notify_router (int gw_nalid, ptl_nid_t gw_nid, ...@@ -162,9 +162,12 @@ kportal_notify_router (int gw_nalid, ptl_nid_t gw_nid,
int rc; int rc;
kpr_control_interface_t *ci; kpr_control_interface_t *ci;
/* No error if router not preset. Sysadmin is allowed to notify
* _everywhere_ when a NID boots or crashes, even if they know
* nothing of the peer. */
ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface); ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface);
if (ci == NULL) if (ci == NULL)
return (-ENODEV); return (0);
rc = ci->kprci_notify (gw_nalid, gw_nid, alive, when); rc = ci->kprci_notify (gw_nalid, gw_nid, alive, when);
......
...@@ -149,14 +149,14 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -149,14 +149,14 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
int alive, time_t when) int alive, time_t when)
{ {
unsigned long flags; unsigned long flags;
int rc = -ENOENT; int found;
kpr_nal_entry_t *ne = NULL; kpr_nal_entry_t *ne = NULL;
kpr_gateway_entry_t *ge = NULL; kpr_gateway_entry_t *ge = NULL;
struct timeval now; struct timeval now;
struct list_head *e; struct list_head *e;
struct list_head *n; struct list_head *n;
CDEBUG (D_ERROR, "%s notifying [%d] "LPX64": %s\n", CDEBUG (D_NET, "%s notifying [%d] "LPX64": %s\n",
byNal ? "NAL" : "userspace", byNal ? "NAL" : "userspace",
gateway_nalid, gateway_nid, alive ? "up" : "down"); gateway_nalid, gateway_nid, alive ? "up" : "down");
...@@ -177,6 +177,7 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -177,6 +177,7 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
/* Serialise with lookups (i.e. write lock) */ /* Serialise with lookups (i.e. write lock) */
write_lock_irqsave(&kpr_rwlock, flags); write_lock_irqsave(&kpr_rwlock, flags);
found = 0;
list_for_each_safe (e, n, &kpr_gateways) { list_for_each_safe (e, n, &kpr_gateways) {
ge = list_entry(e, kpr_gateway_entry_t, kpge_list); ge = list_entry(e, kpr_gateway_entry_t, kpge_list);
...@@ -185,15 +186,15 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -185,15 +186,15 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
ge->kpge_nid != gateway_nid) ge->kpge_nid != gateway_nid)
continue; continue;
rc = 0; found = 1;
break; break;
} }
if (rc != 0) { if (!found) {
/* gateway not found */ /* gateway not found */
write_unlock_irqrestore(&kpr_rwlock, flags); write_unlock_irqrestore(&kpr_rwlock, flags);
CDEBUG (D_NET, "Gateway not found\n"); CDEBUG (D_NET, "Gateway not found\n");
return (rc); return (0);
} }
if (when < ge->kpge_timestamp) { if (when < ge->kpge_timestamp) {
...@@ -226,25 +227,24 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -226,25 +227,24 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
} }
} }
found = 0;
if (!byNal) { if (!byNal) {
/* userland notified me: notify NAL? */ /* userland notified me: notify NAL? */
ne = kpr_find_nal_entry_locked (ge->kpge_nalid); ne = kpr_find_nal_entry_locked (ge->kpge_nalid);
if (ne != NULL) { if (ne != NULL) {
if (ne->kpne_shutdown || if (!ne->kpne_shutdown &&
ne->kpne_interface.kprni_notify == NULL) { ne->kpne_interface.kprni_notify != NULL) {
/* no need to notify */
ne = NULL;
} else {
/* take a ref on this NAL until notifying /* take a ref on this NAL until notifying
* it has completed... */ * it has completed... */
atomic_inc (&ne->kpne_refcount); atomic_inc (&ne->kpne_refcount);
found = 1;
} }
} }
} }
write_unlock_irqrestore(&kpr_rwlock, flags); write_unlock_irqrestore(&kpr_rwlock, flags);
if (ne != NULL) { if (found) {
ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg, ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg,
gateway_nid, alive); gateway_nid, alive);
/* 'ne' can disappear now... */ /* 'ne' can disappear now... */
......
...@@ -154,7 +154,7 @@ ptl_parse_time (time_t *t, char *str) ...@@ -154,7 +154,7 @@ ptl_parse_time (time_t *t, char *str)
return (0); return (0);
memset (&tm, 0, sizeof (tm)); memset (&tm, 0, sizeof (tm));
n = sscanf (str, "%d-%d-%d %d:%d:%d", n = sscanf (str, "%d-%d-%d-%d:%d:%d",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec); &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
if (n != 6) if (n != 6)
...@@ -1338,7 +1338,7 @@ jt_ptl_notify_router (int argc, char **argv) ...@@ -1338,7 +1338,7 @@ jt_ptl_notify_router (int argc, char **argv)
when = now.tv_sec; when = now.tv_sec;
} else if (ptl_parse_time (&when, argv[3]) != 0) { } else if (ptl_parse_time (&when, argv[3]) != 0) {
fprintf(stderr, "Can't parse time %s\n" fprintf(stderr, "Can't parse time %s\n"
"Please specify either 'YYYY-MM-DD HH:MM:SS'\n" "Please specify either 'YYYY-MM-DD-HH:MM:SS'\n"
"or an absolute unix time in seconds\n", argv[3]); "or an absolute unix time in seconds\n", argv[3]);
return (-1); return (-1);
} else if (when > now.tv_sec) { } else if (when > now.tv_sec) {
......
...@@ -162,9 +162,12 @@ kportal_notify_router (int gw_nalid, ptl_nid_t gw_nid, ...@@ -162,9 +162,12 @@ kportal_notify_router (int gw_nalid, ptl_nid_t gw_nid,
int rc; int rc;
kpr_control_interface_t *ci; kpr_control_interface_t *ci;
/* No error if router not preset. Sysadmin is allowed to notify
* _everywhere_ when a NID boots or crashes, even if they know
* nothing of the peer. */
ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface); ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface);
if (ci == NULL) if (ci == NULL)
return (-ENODEV); return (0);
rc = ci->kprci_notify (gw_nalid, gw_nid, alive, when); rc = ci->kprci_notify (gw_nalid, gw_nid, alive, when);
......
...@@ -149,14 +149,14 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -149,14 +149,14 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
int alive, time_t when) int alive, time_t when)
{ {
unsigned long flags; unsigned long flags;
int rc = -ENOENT; int found;
kpr_nal_entry_t *ne = NULL; kpr_nal_entry_t *ne = NULL;
kpr_gateway_entry_t *ge = NULL; kpr_gateway_entry_t *ge = NULL;
struct timeval now; struct timeval now;
struct list_head *e; struct list_head *e;
struct list_head *n; struct list_head *n;
CDEBUG (D_ERROR, "%s notifying [%d] "LPX64": %s\n", CDEBUG (D_NET, "%s notifying [%d] "LPX64": %s\n",
byNal ? "NAL" : "userspace", byNal ? "NAL" : "userspace",
gateway_nalid, gateway_nid, alive ? "up" : "down"); gateway_nalid, gateway_nid, alive ? "up" : "down");
...@@ -177,6 +177,7 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -177,6 +177,7 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
/* Serialise with lookups (i.e. write lock) */ /* Serialise with lookups (i.e. write lock) */
write_lock_irqsave(&kpr_rwlock, flags); write_lock_irqsave(&kpr_rwlock, flags);
found = 0;
list_for_each_safe (e, n, &kpr_gateways) { list_for_each_safe (e, n, &kpr_gateways) {
ge = list_entry(e, kpr_gateway_entry_t, kpge_list); ge = list_entry(e, kpr_gateway_entry_t, kpge_list);
...@@ -185,15 +186,15 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -185,15 +186,15 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
ge->kpge_nid != gateway_nid) ge->kpge_nid != gateway_nid)
continue; continue;
rc = 0; found = 1;
break; break;
} }
if (rc != 0) { if (!found) {
/* gateway not found */ /* gateway not found */
write_unlock_irqrestore(&kpr_rwlock, flags); write_unlock_irqrestore(&kpr_rwlock, flags);
CDEBUG (D_NET, "Gateway not found\n"); CDEBUG (D_NET, "Gateway not found\n");
return (rc); return (0);
} }
if (when < ge->kpge_timestamp) { if (when < ge->kpge_timestamp) {
...@@ -226,25 +227,24 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ...@@ -226,25 +227,24 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid,
} }
} }
found = 0;
if (!byNal) { if (!byNal) {
/* userland notified me: notify NAL? */ /* userland notified me: notify NAL? */
ne = kpr_find_nal_entry_locked (ge->kpge_nalid); ne = kpr_find_nal_entry_locked (ge->kpge_nalid);
if (ne != NULL) { if (ne != NULL) {
if (ne->kpne_shutdown || if (!ne->kpne_shutdown &&
ne->kpne_interface.kprni_notify == NULL) { ne->kpne_interface.kprni_notify != NULL) {
/* no need to notify */
ne = NULL;
} else {
/* take a ref on this NAL until notifying /* take a ref on this NAL until notifying
* it has completed... */ * it has completed... */
atomic_inc (&ne->kpne_refcount); atomic_inc (&ne->kpne_refcount);
found = 1;
} }
} }
} }
write_unlock_irqrestore(&kpr_rwlock, flags); write_unlock_irqrestore(&kpr_rwlock, flags);
if (ne != NULL) { if (found) {
ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg, ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg,
gateway_nid, alive); gateway_nid, alive);
/* 'ne' can disappear now... */ /* 'ne' can disappear now... */
......
...@@ -154,7 +154,7 @@ ptl_parse_time (time_t *t, char *str) ...@@ -154,7 +154,7 @@ ptl_parse_time (time_t *t, char *str)
return (0); return (0);
memset (&tm, 0, sizeof (tm)); memset (&tm, 0, sizeof (tm));
n = sscanf (str, "%d-%d-%d %d:%d:%d", n = sscanf (str, "%d-%d-%d-%d:%d:%d",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec); &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
if (n != 6) if (n != 6)
...@@ -1338,7 +1338,7 @@ jt_ptl_notify_router (int argc, char **argv) ...@@ -1338,7 +1338,7 @@ jt_ptl_notify_router (int argc, char **argv)
when = now.tv_sec; when = now.tv_sec;
} else if (ptl_parse_time (&when, argv[3]) != 0) { } else if (ptl_parse_time (&when, argv[3]) != 0) {
fprintf(stderr, "Can't parse time %s\n" fprintf(stderr, "Can't parse time %s\n"
"Please specify either 'YYYY-MM-DD HH:MM:SS'\n" "Please specify either 'YYYY-MM-DD-HH:MM:SS'\n"
"or an absolute unix time in seconds\n", argv[3]); "or an absolute unix time in seconds\n", argv[3]);
return (-1); return (-1);
} else if (when > now.tv_sec) { } else if (when > now.tv_sec) {
......
...@@ -101,7 +101,7 @@ command_t cmdlist[] = { ...@@ -101,7 +101,7 @@ command_t cmdlist[] = {
"usage: del_route <gateway> [<target>] [<target>]"}, "usage: del_route <gateway> [<target>] [<target>]"},
{"set_route", jt_ptl_notify_router, 0, {"set_route", jt_ptl_notify_router, 0,
"enable/disable routes via the given gateway in the portals routing table\n" "enable/disable routes via the given gateway in the portals routing table\n"
"usage: set_gw <gateway> <up/down> [<time>]"}, "usage: set_route <gateway> <up/down> [<time>]"},
{"route_list", jt_ptl_print_routes, 0, "print the portals routing table\n" {"route_list", jt_ptl_print_routes, 0, "print the portals routing table\n"
"usage: route_list"}, "usage: route_list"},
{"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, " {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment