[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框架流程圖里。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM