Skip to content

fukuda-lab/OpenPCC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SRv6 PCC for End.Replicate

RFC 9524 SRv6 Replication対応のPCEP Path Computation Client (PCC)実装

概要

このPCCは、SRv6のEnd.Replicate機能を使用したマルチキャスト配信のために、 PCE (Path Computation Element)と連携してパス計算とレプリケーション制御を行います。

機能

  • PCEP基本プロトコル実装 (RFC 5440準拠)
  • マルチキャストJoin/Leave拡張メッセージ
  • SRv6 End.Replicateカーネルモジュールとの連携
  • 動的なレプリケーションパス更新

前提条件

  • Linux kernel with SRv6 support
  • RFC9524カーネルモジュール (srv6-rfc9524-repl.ko) がロード済み
  • PCEサーバーが稼働中

ビルド

cd /home/tanabe/work/mp-srv6/mp-srv6/srv6-pcc
make

実行

このPCCはIPv4とIPv6の両方に対応しています。アドレスファミリは自動検出されます。

# IPv6でPCEに接続
sudo ./build/srv6-pcc -p fc00::1 -l fc00::2

# IPv4でPCEに接続
sudo ./build/srv6-pcc -p 192.168.1.1 -l 192.168.1.2

# ポート指定
sudo ./build/srv6-pcc -p fc00::1 -l fc00::2 -P 4189

# オプション:
#   -p : PCEアドレス (IPv4またはIPv6、必須、自動検出)
#   -l : ローカルアドレス (PCEと同じアドレスファミリ、必須)
#   -P : PCEポート (デフォルト: 4189)
#   -k : Keepaliveタイマー (秒, デフォルト: 30)
#   -d : Deadタイマー (秒, デフォルト: 120)
#   -h : ヘルプ表示

アドレスファミリの自動検出

PCCは指定されたPCEアドレスからIPv4/IPv6を自動判定します:

  • IPv6形式 (例: fc00::1, 2001:db8::1) → IPv6モードで動作
  • IPv4形式 (例: 192.168.1.1, 10.0.0.1) → IPv4モードで動作

ローカルアドレスはPCEアドレスと同じアドレスファミリである必要があります。

カーネルモジュール連携

このPCCは、RFC9524カーネルモジュールのsysfsインターフェースを使用して、 レプリケーション設定を動的に更新します。

カーネルモジュール確認

# モジュールがロードされているか確認
lsmod | grep srv6_rfc9524

# sysfsインターフェース確認
ls -la /sys/kernel/srv6_rfc9524/

設定例

PCEからMCAST_UPDATEを受信すると、以下のような操作が自動実行されます:

# 宛先追加 (PCCが自動実行)
echo "fc00::10 fc00::a,fc00::b,fc00::c" > /sys/kernel/srv6_rfc9524/add_destination

# レプリケーションパラメータ設定
echo "fc00::10 100 0x1" > /sys/kernel/srv6_rfc9524/set_rep_param

アーキテクチャ

[PCE Server]
     |
     | PCEP (TCP 4189)
     | - MCAST_JOIN/LEAVE
     | - MCAST_UPDATE
     |
[srv6-pcc]
     |
     | sysfs interface
     | (/sys/kernel/srv6_rfc9524/*)
     |
[srv6-rfc9524-repl.ko]
     |
     | Netfilter hooks
     |
[Network Stack] <--- SRv6 End.Replicate処理

PCEPメッセージフロー

1. セッション確立

PCC → PCE: OPEN (session parameters)
PCE → PCC: OPEN
PCC → PCE: KEEPALIVE
PCE → PCC: KEEPALIVE
(Session UP)

2. Join処理

PCC → PCE: MCAST_JOIN (group_id, client_addr, QoS)
PCE: パス計算・ツリー最適化
PCE → PCC: MCAST_UPDATE (SRv6 path with SID list)
PCC: カーネルモジュール設定更新

3. Leave処理

PCC → PCE: MCAST_LEAVE (group_id, client_addr)
PCE: ツリー再計算
PCE → PCC: MCAST_UPDATE (updated paths)
PCC: カーネルモジュール設定更新

デバッグ

ログ確認

# PCCログ (標準出力)
./build/srv6-pcc -p fc00::1 -l fc00::2

# カーネルモジュールログ
dmesg | grep rfc9524

状態確認

# 宛先リスト表示
cat /sys/kernel/srv6_rfc9524/show_destinations

# 統計情報表示
cat /sys/kernel/srv6_rfc9524/stats

トラブルシューティング

1. PCEに接続できない

# PCEが稼働しているか確認
ping6 fc00::1
nc -6 -v fc00::1 4189

# ファイアウォール確認
ip6tables -L -n

2. カーネルモジュールが見つからない

# モジュールロード
sudo insmod /path/to/srv6-rfc9524-repl.ko

# モジュール設定確認
ls -la /sys/kernel/srv6_rfc9524/

3. 宛先追加に失敗

# sysfsパーミッション確認
ls -la /sys/kernel/srv6_rfc9524/add_destination

# カーネルログ確認
dmesg | tail -20

ライセンス

MIT

作者

Taisei Tanabe

参考文献

  • RFC 5440: Path Computation Element (PCE) Communication Protocol (PCEP)
  • RFC 8231: Path Computation Element Communication Protocol (PCEP) Extensions for Stateful PCE
  • RFC 9524: Segment Routing Replication for Multicast using SR-MPLS and SRv6

This file will contain the main function and the implementation of the SRv6 PCC functionality.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include "srv6_pcc.h"

// Global variables
struct srv6_pcc pcc;

// Function to initialize the PCC
int srv6_pcc_init(void) {
    memset(&pcc, 0, sizeof(pcc));
    return 0;
}

// Function to exit the PCC
void srv6_pcc_exit(void) {
    // Cleanup if necessary
}

// Function to add a destination
int srv6_pcc_add_destination(const char *dest, const char *sids) {
    // Parse destination and SIDs
    if (inet_pton(AF_INET6, dest, &pcc.dest_addr) != 1) {
        perror("Invalid destination address");
        return -1;
    }

    // Parse SIDs
    char *sid_token = strtok(sids, ",");
    while (sid_token && pcc.sid_count < MAX_SIDS) {
        if (inet_pton(AF_INET6, sid_token, &pcc.sids[pcc.sid_count]) != 1) {
            perror("Invalid SID address");
            return -1;
        }
        pcc.sid_count++;
        sid_token = strtok(NULL, ",");
    }

    printf("Added destination: %s with SIDs: ", dest);
    for (int i = 0; i < pcc.sid_count; i++) {
        char str[INET6_ADDRSTRLEN];
        inet_ntop(AF_INET6, &pcc.sids[i], str, sizeof(str));
        printf("%s ", str);
    }
    printf("\n");
    return 0;
}

// Function to remove a destination
int srv6_pcc_remove_destination(const char *dest) {
    // Implement removal logic
    printf("Removed destination: %s\n", dest);
    return 0;
}

// Function to list destinations
void srv6_pcc_list_destinations(void) {
    // Implement listing logic
    printf("Listing destinations...\n");
}

// Function to set parameters
int srv6_pcc_set_params(const char *params) {
    // Implement parameter setting logic
    printf("Set parameters: %s\n", params);
    return 0;
}

// Main function
int main(int argc, char *argv[]) {
    if (srv6_pcc_init() != 0) {
        fprintf(stderr, "Failed to initialize SRv6 PCC\n");
        return EXIT_FAILURE;
    }

    // Example usage
    if (argc > 2) {
        if (strcmp(argv[1], "add") == 0) {
            srv6_pcc_add_destination(argv[2], argv[3]);
        } else if (strcmp(argv[1], "remove") == 0) {
            srv6_pcc_remove_destination(argv[2]);
        } else if (strcmp(argv[1], "list") == 0) {
            srv6_pcc_list_destinations();
        } else if (strcmp(argv[1], "set") == 0) {
            srv6_pcc_set_params(argv[2]);
        }
    } else {
        fprintf(stderr, "Usage: %s <command> <args>\n", argv[0]);
    }

    srv6_pcc_exit();
    return EXIT_SUCCESS;
}

Build the Project

  1. Create a Makefile

Create a Makefile in the project root directory to compile the project.

CC = gcc
CFLAGS = -Iinclude
SRC = src/main.c
TARGET = srv6_pcc

all: $(TARGET)

$(TARGET): $(SRC)
	$(CC) $(CFLAGS) -o $(TARGET) $(SRC)

clean:
	rm -f $(TARGET)
  1. Build the Project

Run the following command to build your project:

make

Usage

You can run the compiled binary with commands to add, remove, list destinations, or set parameters:

./srv6_pcc add <destination> <sid1,sid2,...>
./srv6_pcc remove <destination>
./srv6_pcc list
./srv6_pcc set <params>

Conclusion

This is a basic implementation of the SRv6 PCC functionality for End.Replicate. You can expand upon this by adding more features, error handling, and integrating it with the existing SRv6 infrastructure as needed.

About

Path Computation Client for Linux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages