Linux内核中各个子系统相互依赖,当其中某个子系统状态发生改变时,就必须使用一定的机制告知使用其服务的其他子系统,以便其他子系统采取相应的措施。为满足这样的需求,内核实现了事件通知链机制(notification chain)。

struct notifier_block {
       int (*notifier_call)(struct notifier_block *, unsigned long, void *);
       struct notifier_block *next;
       int priority;
};

  此处只要注意一个 priority 优先级,参见下面一段代码(./net/rds/tcp.c p382)

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
static struct notifier_block rds_tcp_dev_notifier = {                                                                                                   
    .notifier_call        = rds_tcp_dev_event,
    .priority = -10, /* must be called after other network notifiers */
};

  想要接受一个通知链信息需要自己设置两个参数:通知链调用函数,优先级。

  优先级能够控制函数调用的顺序,默认优先级为 0,数字越小表示越晚被调用。

 

  看着很简单吧,哈哈哈,方案暂时不用这个啦,回头再看,:)。

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄