netconf confirmed-commit 能力

netconf confirmed-commit能力

netconf系列分享



前言

近期用到了netconf相关功能,对其中的confirmed-commit功能进行分享


一、环境信息

嵌入式linux

uname -a
Linux (none) 4.19.26 #1 SMP PREEMPT Tue Jan 19 16:15:19 CST 2021 aarch64 GNU/Linux

相关软件版本:

# sysrepoctl -V
sysrepoctl - sysrepo YANG schema manipulation tool, compiled with libsysrepo v1.4.70 (SO v5.5.12)
# netopeer2-server -V
netopeer2-server 1.1.39
compile time: Oct 27 2020, 14:21:33

libnetconf: libyang-1.0.215.tar.gz

二、基本原理

confirmed-commit:1.1能力表示服务器将支持confirmed等参数,如果在超时期限内没有发出确认提交,默认的commit操作必须被恢复(默认600秒= 10分钟)

1.能力初始化

confirmed-commit作为ietf-netconf.yang标准模型支持的能力,在使用前需要进行初始化

通过sysrepoctl工具使能confirmed-commit能力

sysrepoctl -a -c ietf-netconf -e confirmed-commit -v2

操作成功后,可通过如下命令查询当前yang模型支持的能力情况,可看到confirmed-commit能力已使能
# sysrepoctl -l
Sysrepo repository: /mnt/flash2/sysrepo

Module Name                | Revision   | Flags | Owner     | Permissions | Submodules | Features                                                                                
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                                                                      
ietf-netconf               | 2013-09-29 | I     | root:root | 600         |            | writable-running candidate rollback-on-error validate startup url xpath confirmed-commit

2.功能验证

1. 下发配置到candidate数据库
<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
     xmlns:pcl-ethernet="urn:pcl:params:xml:ns:yang:example"
     message-id="1">
  <edit-config>
    <target>
      <candidate/>
    </target>
    <config>
      <examples xmlns="urn:ietf:params:xml:ns:yang:example">
        <example>
          <name>hello</name>
        </examples>
      </examples>
    </config>
  </edit-config>
</rpc>


2. 下发confirmed-commit命令,配置超时时间为10s
<rpc message-id="101"
    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <commit>
        <confirmed/>
        <confirm-timeout>10</confirm-timeout>
    </commit>
</rpc>

3.收到应答
<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="25">
  <ok/>
</rpc-reply>

4.通过sysrepocfg命令分别查询candidate和runnning数据库信息
sysrepocfg -d candidate-m examples -X
sysrepocfg -d running -m examples -X

发现配置到candidate数据库后,执行confirmed-commit命令会立即生效到running数据库,没有timeout的延时。

3.源码分析

np2srv_rpc_commit_cb, 这个函数并不解析commit参数,阅读源码发现不支持confirmed-commit

总结

查询github,作者表示netopeer暂时还不支持confirmed-commit能力。暂时修改源码支持此能力,待github升级版本后再进行替换。
修改的源码主要在 np2srv_rpc_commit_cb 部分

https://github.com/CESNET/netopeer2/issues/864
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值