Monday, May 25, 2009

link状态上报

在phy的内核线程里,会周期性的通过MII查询link状态.
        if (phydev->link) {
                phydev->state = PHY_RUNNING;
                netif_carrier_on(phydev->attached_dev);
            } else {
                phydev->state = PHY_NOLINK;
                netif_carrier_off(phydev->attached_dev);
            }

然后通过下面两个函数来进行处理:,
void netif_carrier_on(struct net_device *dev)
{
    if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state))
        linkwatch_fire_event(dev);
    if (netif_running(dev))
        __netdev_watchdog_up(dev);
}

void netif_carrier_off(struct net_device *dev)
{
    if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state))
        linkwatch_fire_event(dev);
}
会把状态设到dev->state里.  并调用linkwatch_fire_event来在list:lweventlist中添加一个节点.并由workqueue:linkwatch_work来处理.主要的处理流程为:进行一些协议栈方面的维护工作, 然后调用 netdev_state_change 来notify netdev_chain(事件为NETDEV_CHANGE),以及rtmsg_ifinfo来向group:RTNLGRP_LINK广播RTM_NEWLINK信息.   注册 netdev_chain的包括 rtnetlink. 但其在回调里没作处理. 用户程序通过netlink接收RTNLGRP_LINK的消息即可及时得到通知.

gnome的NetworkManager以及ifplugd间接或直接的使用这种机制.

3 comments:

Anonymous said...

the challenges in pharmacy http://drugstore4.com/fr/product/avapro.html clayton pharmacy [url=http://drugstore4.com/product/biaxin.html]biaxin[/url]
ohio pharmacy board http://drugstore4.com/fr/category/angoisse.html postgraduate degree in clinical pharmacy [url=http://drugstore4.com/de/product/himalaya-menosan.html]babis pharmacy in wynnewood[/url]
pharmacy fraud in credit card billing new york city http://drugstore4.com/product/alesse.html cvs pharmacy stores [url=http://drugstore4.com/de/product/prograf.html]prograf[/url]
cvs pharmacy and utah http://drugstore4.com/fr/product/cialis-super-active.html sav on pharmacy in murrieta california [url=http://drugstore4.com/category/allergies.html]new orleans pharmacy museum[/url]

Anonymous said...

movie theatres for sale http://moviestrawberry.com/films/film_trailer_park_of_terror/ caravan movie tibet [url=http://moviestrawberry.com/films/film_trick_or_treat/]trick or treat[/url]
beastiality movie http://moviestrawberry.com/films/film_shark_in_venice/ basic instinct movie clips [url=http://moviestrawberry.com/films/film_p2/]movie japanese heroes trailer[/url]
ago days evil homer world top yahoo chart movie film http://moviestrawberry.com/films/film_dirty_deeds/ gorillaz movie [url=http://moviestrawberry.com/films/film_the_unknown_marx_brothers/]the unknown marx brothers[/url]
primer movie http://moviestrawberry.com/films/film_ali_baba_goes_to_town/ time machine movie [url=http://moviestrawberry.com/films/film_wanted/]hbo movie line up[/url]
halloween movie download http://moviestrawberry.com/easy-downloads/letter_I/?page=6 download windos movie maker [url=http://moviestrawberry.com/films/film_twilight/]twilight[/url]
schweinehund animated movie by ravenstein http://moviestrawberry.com/hqmoviesbycountry/country_south_africa/ free bootleg movie sites [url=http://moviestrawberry.com/films/film_unholy/]full movie forumz[/url]

Anonymous said...

rock o n tv http://kzq.in/kiss/ashley/tisdale/and/vanessa/hudgens/kiss advanced mp3 recorder [url=http://kzq.in/madonna/madonna/topeless/fashion/show]madonna topeless fashion show[/url]
free pop up window killers http://kzq.in/jovi/back/stage/with/bon/jovi gothic dress up games [url=http://kzq.in/kylie-minogue/kylie/minogue/children]libra drum and bass[/url]
tupac poem critic reviews http://kzq.in/jimi-hendrix/did/jimi/hendrix leonard redman sacramento [url=http://kzq.in/michael-jackson/videos/con/michael/jackson]videos con michael jackson[/url]
call me crazy mp3 http://kzq.in/lupe-fiasco vital music [url=http://kzq.in/iron-maiden/iron/maiden/beer/mugs]loz sheet music[/url]
ancient quotes about music http://kzq.in/kiss/chocolate/kiss/mouse/treats gospel church 116th street harlem [url=http://kzq.in/kanye-west/kanye/west/stronger/glasses/for/sale]kanye west stronger glasses for sale[/url]
lyrics should i stay or should i go clash http://kzq.in/madonna/sexy/madonna/pictures download chronicles of narnia prince caspian [url=http://kzq.in/killers/killers/real/cast/crew/full/credit/fan/movie]traditional irish music courses[/url]