2005-01-29 Dan Williams <dcbw@redhat.com>

* initscript/RedHat/NetworkManager
		- Don't spit out sysctl stuff to console

	* libnm_glib/libnm_glib.c
		- (libnm_glib_init): call dbus_g_thread_init()

	* panel-applet/NMWirelessAppletDbus.c
		- (nmwa_dbus_worker): call dbus_g_thread_init()

	* src/NetworkManager.c
		- (main): call dbus_g_thread_init()

	* src/NetworkManagerAPList.c
		- (nm_ap_list_print_members): use LOG_ERR instead of LOG_DEBUG
			so we can actually see what's there in a normal syslog

	* src/NetworkManagerDevice.c
		- (nm_device_activate_wireless): print out the "waiting for access point"
			message only once, then say what access point we actually got after
			the wait.
		- (nm_device_need_ap_switch): If a scan is in progress when we're in this
			function, wait until the scan is done.  Scans may change the ESSID of
			the card, making this function think we need to switch access points
		- (nm_device_wireless_process_scan_results): for artificial access points
			don't check against the card's ESSID, but the best_ap's ESSID.  This
			prevents collisions with the scanning code, which may change the card's
			ESSID and cause the access point to get dropped from the device's AP
			list.  Also increase the keep-around time to 2m from 60s since the max
			scan interval could be 60s in some cases.

	* src/NetworkManagerPolicy.c
		- (nm_policy_activation_finish): Don't add invalid MAC addresses to GConf
		- (nm_policy_allowed_ap_list_update): When we update, make sure we copy over
			the new properties and ESSIDs to the device's AP list.  Fixes some races
			between NM and NMI.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@401 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2005-01-29 23:34:31 +00:00
parent 37fa2d08a4
commit 2827e5129c
8 changed files with 83 additions and 17 deletions

View File

@@ -1,3 +1,41 @@
2005-01-29 Dan Williams <dcbw@redhat.com>
* initscript/RedHat/NetworkManager
- Don't spit out sysctl stuff to console
* libnm_glib/libnm_glib.c
- (libnm_glib_init): call dbus_g_thread_init()
* panel-applet/NMWirelessAppletDbus.c
- (nmwa_dbus_worker): call dbus_g_thread_init()
* src/NetworkManager.c
- (main): call dbus_g_thread_init()
* src/NetworkManagerAPList.c
- (nm_ap_list_print_members): use LOG_ERR instead of LOG_DEBUG
so we can actually see what's there in a normal syslog
* src/NetworkManagerDevice.c
- (nm_device_activate_wireless): print out the "waiting for access point"
message only once, then say what access point we actually got after
the wait.
- (nm_device_need_ap_switch): If a scan is in progress when we're in this
function, wait until the scan is done. Scans may change the ESSID of
the card, making this function think we need to switch access points
- (nm_device_wireless_process_scan_results): for artificial access points
don't check against the card's ESSID, but the best_ap's ESSID. This
prevents collisions with the scanning code, which may change the card's
ESSID and cause the access point to get dropped from the device's AP
list. Also increase the keep-around time to 2m from 60s since the max
scan interval could be 60s in some cases.
* src/NetworkManagerPolicy.c
- (nm_policy_activation_finish): Don't add invalid MAC addresses to GConf
- (nm_policy_allowed_ap_list_update): When we update, make sure we copy over
the new properties and ESSIDs to the device's AP list. Fixes some races
between NM and NMI.
2005-01-27 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfoDbus.c

View File

@@ -28,7 +28,8 @@ RETVAL=0
start()
{
action $"Setting network parameters: " sysctl -e -p /etc/sysctl.conf
echo $"Setting network parameters... "
sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
echo -n $"Starting NetworkManager daemon: "
daemon --check $servicename $processname
RETVAL=$?

View File

@@ -472,6 +472,7 @@ libnm_glib_ctx *libnm_glib_init (void)
g_type_init ();
if (!g_thread_supported ())
g_thread_init (NULL);
dbus_g_thread_init ();
ctx = libnm_glib_ctx_new();
if (!ctx)

View File

@@ -1263,6 +1263,8 @@ gpointer nmwa_dbus_worker (gpointer user_data)
g_return_val_if_fail (applet != NULL, NULL);
dbus_g_thread_init ();
if (!(applet->thread_context = g_main_context_new ()))
return (NULL);
if (!(thread_loop = g_main_loop_new (applet->thread_context, FALSE)))

View File

@@ -703,6 +703,7 @@ int main( int argc, char *argv[] )
g_type_init ();
if (!g_thread_supported ())
g_thread_init (NULL);
dbus_g_thread_init ();
openlog ("NetworkManager", (become_daemon) ? LOG_CONS : LOG_CONS | LOG_PERROR, (become_daemon) ? LOG_DAEMON : LOG_USER);
syslog (LOG_NOTICE, "starting...");

View File

@@ -659,16 +659,16 @@ void nm_ap_list_print_members (NMAccessPointList *list, const char *name)
if (!(iter = nm_ap_list_iter_new (list)))
return;
syslog (LOG_DEBUG, "AP_LIST_PRINT: printing members of '%s'", name);
syslog (LOG_ERR, "AP_LIST_PRINT: printing members of '%s'", name);
while ((ap = nm_ap_list_iter_next (iter)))
{
const GTimeVal *timestamp = nm_ap_get_timestamp (ap);
syslog (LOG_DEBUG, "\t%d)\tobj=%p, essid='%s', timestamp=%ld, key='%s', enc=%d, addr=%p, strength=%d, freq=%f, rate=%d, inval=%d, mode=%d",
syslog (LOG_ERR, "\t%d)\tobj=%p, essid='%s', timestamp=%ld, key='%s', enc=%d, addr=%p, strength=%d, %s=%f, rate=%d, inval=%d, mode=%d",
i, ap, nm_ap_get_essid (ap), timestamp->tv_sec, nm_ap_get_enc_key_source (ap), nm_ap_get_encrypted (ap),
nm_ap_get_address (ap), nm_ap_get_strength (ap), nm_ap_get_freq (ap), nm_ap_get_rate (ap),
nm_ap_get_address (ap), nm_ap_get_strength (ap), (nm_ap_get_freq (ap) < 20) ? "channel" : "freq", nm_ap_get_freq (ap), nm_ap_get_rate (ap),
nm_ap_get_invalid (ap), nm_ap_get_mode (ap));
i++;
}
syslog (LOG_DEBUG, "AP_LIST_PRINT: done");
syslog (LOG_ERR, "AP_LIST_PRINT: done");
nm_ap_list_iter_free (iter);
}

View File

@@ -1845,7 +1845,7 @@ static gboolean nm_device_wireless_wait_for_link (NMDevice *dev, const char *ess
/*
* nm_device_activate_wireless
* nm_device_set_wireless_config
*
* Bring up a wireless card with the essid and wep key of its "best" ap
*
@@ -2097,6 +2097,7 @@ static gboolean nm_device_activate_wireless (NMDevice *dev)
guint8 attempt = 1;
char last_essid [50] = "\0";
gboolean need_key = FALSE;
gboolean found_ap = FALSE;
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (dev->app_data != NULL, FALSE);
@@ -2122,7 +2123,8 @@ get_ap:
while (!(best_ap = nm_device_get_best_ap (dev)))
{
nm_device_set_now_scanning (dev, TRUE);
syslog (LOG_DEBUG, "Activation (%s/wireless): waiting for an access point.", nm_device_get_iface (dev));
if (!found_ap)
syslog (LOG_ERR, "Activation (%s/wireless): waiting for an access point.", nm_device_get_iface (dev));
g_usleep (G_USEC_PER_SEC * 2);
/* If we were told to quit activation, stop the thread and return */
@@ -2132,7 +2134,10 @@ get_ap:
g_mutex_lock (dev->options.wireless.scan_mutex);
goto out;
}
found_ap = TRUE;
}
if (found_ap)
syslog (LOG_ERR, "Activation (%s/wireless): found access point '%s' to use.", nm_device_get_iface (dev), nm_ap_get_essid (best_ap));
/* Set ESSID early so that when we send out the DeviceStatusChanged signal below,
* we are able to respond correctly to queries for "getActiveNetwork" against
@@ -2384,7 +2389,7 @@ static gboolean nm_device_activate (gpointer user_data)
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (dev->app_data != NULL, FALSE);
syslog (LOG_DEBUG, "Activation (%s) started...", nm_device_get_iface (dev));
syslog (LOG_ERR, "Activation (%s) started...", nm_device_get_iface (dev));
/* Bring the device up */
if (!nm_device_is_up (dev));
@@ -2822,11 +2827,19 @@ gboolean nm_device_need_ap_switch (NMDevice *dev)
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (nm_device_is_wireless (dev), FALSE);
/* Since the card's ESSID may change during a scan, we need to
* wait until the scan is done, if one is in-progress.
*/
g_mutex_lock (dev->options.wireless.scan_mutex);
ap = nm_device_get_best_ap (dev);
if (nm_null_safe_strcmp (nm_device_get_essid (dev), (ap ? nm_ap_get_essid (ap) : NULL)) != 0)
need_switch = TRUE;
if (ap) nm_ap_unref (ap);
if (ap)
nm_ap_unref (ap);
g_mutex_unlock (dev->options.wireless.scan_mutex);
return (need_switch);
}
@@ -2929,7 +2942,6 @@ void nm_device_update_best_ap (NMDevice *dev)
best_ap = trusted_best_ap ? trusted_best_ap : untrusted_best_ap;
nm_ap_list_iter_free (iter);
/* If the best ap is NULL, bring device down and clear out its essid and AP */
nm_device_set_best_ap (dev, best_ap);
}
@@ -3362,29 +3374,33 @@ static gboolean nm_device_wireless_process_scan_results (gpointer user_data)
NMAccessPoint *outdated_ap;
GSList *outdated_list = NULL;
GSList *elem;
char *essid = nm_device_get_essid (dev);
NMAccessPoint *best_ap = nm_device_get_best_ap (dev);
while ((outdated_ap = nm_ap_list_iter_next (iter)))
{
const GTimeVal *ap_time = nm_ap_get_last_seen (outdated_ap);
gboolean keep_around = FALSE;
/* We don't add an "artifical" APs to the outdated list if it is the
/* We don't add "artifical" APs to the outdated list if it is the
* one the card is currently associated with.
* Some Cisco cards don't report non-ESSID-broadcasting access points
* in their scans even though the card associates with that AP just fine.
*/
if ( nm_ap_get_essid (outdated_ap)
&& !strcmp (essid, nm_ap_get_essid (outdated_ap))
&& (best_ap && (nm_null_safe_strcmp (nm_ap_get_essid (best_ap), nm_ap_get_essid (outdated_ap))) == 0)
&& nm_ap_get_artificial (outdated_ap))
keep_around = TRUE;
/* Eh, we don't care about sub-second time resolution. */
if ((ap_time->tv_sec + 60 < cur_time.tv_sec) && !keep_around)
if ((ap_time->tv_sec + 120 < cur_time.tv_sec) && !keep_around)
outdated_list = g_slist_append (outdated_list, outdated_ap);
}
nm_ap_list_iter_free (iter);
/* nm_device_get_best_ap() refs the ap */
if (best_ap)
nm_ap_unref (best_ap);
/* Ok, now remove outdated ones. We have to do it after the lock
* because nm_ap_list_remove_ap() locks the list too.
*/

View File

@@ -260,7 +260,7 @@ gboolean nm_policy_activation_finish (gpointer user_data)
nm_ap_set_address (ap, &addr);
/* Don't store MAC addresses for non-infrastructure networks */
if (nm_ap_get_mode (ap) == NETWORK_MODE_INFRA)
if ((nm_ap_get_mode (ap) == NETWORK_MODE_INFRA) && nm_ethernet_address_is_valid (&addr))
nm_dbus_add_network_address (data->dbus_connection, NETWORK_TYPE_ALLOWED, nm_ap_get_essid (ap), &addr);
nm_ap_unref (ap);
@@ -492,6 +492,13 @@ static gboolean nm_policy_allowed_ap_list_update (gpointer user_data)
{
NMAccessPoint *best_ap;
/* Once we have the list, copy in any relevant information from our Allowed list and fill
* in the ESSID of base stations that aren't broadcasting their ESSID, if we have their
* MAC address in our allowed list.
*/
nm_ap_list_copy_essids_by_address (nm_device_ap_list_get (data->active_device), data->allowed_ap_list);
nm_ap_list_copy_properties (nm_device_ap_list_get (data->active_device), data->allowed_ap_list);
best_ap = nm_device_get_best_ap (data->active_device);
if (!best_ap)
nm_device_update_best_ap (data->active_device);