扩展日志框架以支持 FWaaS v2

https://bugs.launchpad.net/neutron/+bug/1720727

本文档的所有内容均基于 原始规范,并扩展了对 FWaaS v2 的日志记录功能的支持,该功能在该规范之外的未来工作部分中提到。

我们希望审阅者在继续下面的部分之前检查 原始规范

问题描述

当前的日志框架最初仅支持安全组作为实现。

提议的变更

为了将该功能扩展到支持 FWaaS v2,我们希望提出与 原始规范中的提议的变更部分相比较的信息,如下所示

日志记录实现

目前,日志记录 API 被设计为服务插件。它也被定义为安全组和防火墙等资源的通用日志记录 API。参考实现可以在 [1] 中找到。

服务器端是我们需要处理的一个方面。目前在 Neutron 安全组日志记录实现中,我们有一个请求验证器函数 [2]。这段代码应该从 neutron 移动到 neutron-lib,并且将更加通用,以便它可以处理 Neutron SG 和 FWaaS。此步骤的预期结果是确保此验证器仍然适用于安全组,并且也可以应用于 FWaaS。

关于代理端

对于 L2 层,LoggingExtension 是一个 L2 代理扩展。它适用于所有日志记录资源,例如安全组和防火墙。对于 L3 层,LoggingL3AgentExtension 是一个专门用于防火墙的 L3 代理扩展。这些代理扩展将接收日志记录资源的 CREATED/UPDATED/DELETED 事件,并将这些事件传递给日志驱动程序。每个日志驱动程序定义它支持的资源。对于 FWaaS v2,将实现一个名为 FWaaSv2LoggingDriver 的日志驱动程序。该类将继承自 LoggingDriver 类。

关于驱动端

将实现两个驱动程序,以支持 L2 层(实例)和 L3 层(路由器)。

对于 L2 层,将实现一个名为 FWaaSv2L2LoggingDriver 的驱动程序。它充当控制器程序。此驱动程序会将流量日志插入到 table=91 和 table=92 中,ct_state=NEW 以生成 ACCEPT 事件,并将流量日志插入到 table=93 以生成 DROP 事件。

对于 L3 层,将基于用户命名空间级别的 iptables 实现一个名为 FWaaSv2L3LoggingDriver 的驱动程序。它在网络节点上运行,通过将 NFLOG 规则添加到 iptables 来处理路由器的端口。我们希望提出详细的解决方案如下

  1. iptables 规则的结构。

    我们将引入两个新的链

    • neutron-l3-agent-accepted:记录第一个接受的数据包并接受与防火墙规则匹配的所有数据包。

    • neutron-l3-agent-dropped:记录并丢弃所有数据包。

    启用日志记录时新的 iptables 结构如下

    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination
    neutron-l3-agent-INPUT  all  --  anywhere             anywhere
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination
    neutron-filter-top  all  --  anywhere             anywhere
    neutron-l3-agent-FORWARD  all  --  anywhere             anywhere
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
    neutron-filter-top  all  --  anywhere             anywhere
    neutron-l3-agent-OUTPUT  all  --  anywhere             anywhere
    
    Chain neutron-filter-top (2 references)
    target     prot opt source               destination
    neutron-l3-agent-local  all  --  anywhere             anywhere
    
    Chain neutron-l3-agent-FORWARD (1 references)
    target     prot opt source               destination
    neutron-l3-agent-scope  all  --  anywhere             anywhere
    neutron-l3-agent-iv4dd529723  all  --  anywhere             anywhere
    neutron-l3-agent-ov4dd529723  all  --  anywhere             anywhere
    neutron-l3-agent-fwaas-defau  all  --  anywhere             anywhere
    neutron-l3-agent-fwaas-defau  all  --  anywhere             anywhere
    
    Chain neutron-l3-agent-INPUT (1 references)
    target     prot opt source               destination
    ACCEPT     all  --  anywhere             anywhere             mark match 0x1/0xffff
    DROP       tcp  --  anywhere             anywhere             tcp dpt:9697
    
    Chain neutron-l3-agent-OUTPUT (1 references)
    target     prot opt source               destination
    
    Chain neutron-l3-agent-fwaas-defau (2 references)
    target     prot opt source               destination
    DROP       all  --  anywhere             anywhere
    
    Chain neutron-l3-agent-iv4dd529723 (1 references)
    target     prot opt source               destination
    neutron-l3-agent-dropped       all  --  anywhere             anywhere             state INVALID
    neutron-l3-agent-accepted     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
    neutron-l3-agent-dropped       all  --  anywhere             anywhere
    
    Chain neutron-l3-agent-local (1 references)
    target     prot opt source               destination
    
    Chain neutron-l3-agent-ov4dd529723 (1 references)
    target     prot opt source               destination
    neutron-l3-agent-dropped       all  --  anywhere             anywhere             state INVALID
    neutron-l3-agent-accepted     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
    neutron-l3-agent-accepted     all  --  anywhere             anywhere
    
    Chain neutron-l3-agent-scope (1 references)
    target     prot opt source               destination
    DROP       all  --  anywhere             anywhere             mark match ! 0x4000000/0xffff0000
    
    Chain neutron-l3-agent-fw-chain (2 references)
    target     prot opt source               destination
    ACCEPT     all  --  anywhere             anywhere
    
    chain neutron-l3-agent-accepted
    target     prot opt source               destination
    NFLOG      all  --  anywhere             anywhere             state NEW limit: avg 100/sec burst 25 nflog-prefix  12823226497704342389
    ACCEPT     all  --  anywhere             anywhere
    
    chain neutron-l3-agent-dropped
    target     prot opt source               destination
    NFLOG      all  --  anywhere             anywhere             limit: avg 100/sec burst 25 nflog-prefix  12823226497704342389
    DROP       all  --  anywhere             anywhere
    
  2. 如何捕获数据包并解析数据包信息。这至少需要两个步骤。

    • 首先,我们需要将数据包转储为原始格式。

      • 我们建议为 libnetfilter_log 实现一个 python 绑定,与 [3] 类似。

    • 在获得原始格式的数据包后,我们需要将这些数据解析为人类可读的格式。

      • 为了做到这一点,我们建议使用 ryu [4] 库完成此步骤。PoC 实现如下 [5]

关于如何配置日志记录功能,请参阅 网络指南 以获取详细信息。

预期的 API 行为

本文档以 FWaaS v2 日志记录为例

操作员可以收集某些情况下的安全事件(ALLOW/DROP 或 ALL)

  1. 通过将防火墙组 ID 传递给 resource_id,收集应用于所有实例/路由器端口的特定防火墙组相关的事件。

  2. 通过将防火墙组 ID 传递给 resource_id 及其绑定的 Neutron 端口 ID 传递给 target_id,收集应用于特定实例/路由器的特定防火墙组相关的事件。

  3. 通过将 Neutron 端口 ID 传递给 target_id,收集应用于特定实例的所有防火墙组相关的事件。

  4. 收集项目中的防火墙组相关的事件:在这种情况下,操作员不向 resource_idtarget_id 传递任何值。

API 操作示例

原始规范 相同

数据模型影响

REST API 影响

原始规范 相同

添加对防火墙组作为 loggable_resource 类型支持。为了做到这一点,需要进行两项更改

  • 使请求验证器和 rpc 回调更加通用,以便支持防火墙组。

  • 在 FWaaS 上,使用上述通用方法注册到 Neutron 端。

安全影响

原始规范 相同

通知影响

操作员 CLI 影响

firewall_group 添加到 –resource-type 中的一个。 此外,在支持的日志记录功能的输出中添加 firewall_group

性能影响

原始规范 相同

IPv6 影响

原始规范 相同

其他部署者影响

无,因为它与日志记录功能一起完成。

开发人员影响

社区影响

备选方案

实现

负责人

主要负责人

y-furukawa-2

其他贡献者

hoangcx, annp, cuongnv

工作项

  • 最终确定一种记录数据的方式

  • 实现基于参考实现的 FWaaSv2LoggingDriver

依赖项

测试

原始规范 相同

Tempest 测试

原始规范 相同

功能测试

原始规范 相同

API 测试

原始规范 相同

文档影响

用户文档

原始规范 相同

参考资料