[ipsec][strongswan] strongswan源码分析--(四)plugin加载优先级原理

前言

如前所述,

我们知道,strongswan以插件功能来提供各种各样的功能。插件之间彼此相互提供功能,同时也有可能提供重复的功能。

这个时候,便需要一个优先级关系,来保证先后加载顺序。

 

方法

在配置文件中,有这样一个配置项,配给每一个plugin

charon.plugins.<name>.load

它的值,可以是Yes,NO,可以是数字。Yes,No代表是否启用该插件。通知默认赋予优先级的值1. 优先级值随数字增大,优先级越高。高优先级的会

更先被加载。同优先级的,按插件名字的字母表顺序进行加载。

见:manual strongswan.conf

       charon.load_modular [no]
              If enabled, the list of plugins to load is determined via the value of the charon.plugins.<name>.load options.  In addition to a simple boolean flag that option may  take
              an integer value indicating the priority of a plugin, which would influence the order of a plugin in the plugin list (the default is 1). If two plugins have the same pri‐
              ority their order in the default plugin list is preserved. Enabled plugins not found in that list are ordered alphabetically before other plugins with the same priority.

 

代码

除了manual,我还看见代码,在这两个地方,与之相关。

1.  插件的加载

charon程序的一开始,便进行了所有配置文件的加载。在library_init()函数里。

 

 

 

2. 插件的排序

我知道,最重要的那个插件,就是daemon插件。在daemon插件的init函数中,通过读取1)中load进来的所有配置

完成了,plugin的优先级与排序。

 

 上面两个截图,已经集成在了完整的strongswan框架流程图里。

 

posted on 2019-06-05 16:03  toong  阅读(2411)  评论(0编辑  收藏  举报