Re: [Linuxptp-devel] [PATCH] Add option to bind raw and UDP sockets to interface

2023-03-10 Thread Kamil Zaripov
> Um, unless I'm mistaken, this is unneeded, because you can specify a
> VLAN interface just like a normal interface.  In the kernel, the VLAN
> interface stacks on top of the physical one and passes the time
> stamping APIs through.


It seems that it is true if you create VLAN interface on top of “hardware” 
interface (the one that support PTP):

$ ethtool -T eth1
Time stamping parameters for eth1:
Capabilities:
hardware-transmit (SOF_TIMESTAMPING_TX_HARDWARE)
software-transmit (SOF_TIMESTAMPING_TX_SOFTWARE)
hardware-receive  (SOF_TIMESTAMPING_RX_HARDWARE)
software-receive  (SOF_TIMESTAMPING_RX_SOFTWARE)
software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
hardware-raw-clock(SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
off   (HWTSTAMP_TX_OFF)
on(HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
none  (HWTSTAMP_FILTER_NONE)
all   (HWTSTAMP_FILTER_ALL)

$ ip -j link show vlan1 | jq '.[] | .link’
“eth1"

$ ethtool -T vlan1
Time stamping parameters for vlan1:
Capabilities:
hardware-transmit (SOF_TIMESTAMPING_TX_HARDWARE)
software-transmit (SOF_TIMESTAMPING_TX_SOFTWARE)
hardware-receive  (SOF_TIMESTAMPING_RX_HARDWARE)
software-receive  (SOF_TIMESTAMPING_RX_SOFTWARE)
software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
hardware-raw-clock(SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
off   (HWTSTAMP_TX_OFF)
on(HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
none  (HWTSTAMP_FILTER_NONE)
all   (HWTSTAMP_FILTER_ALL)

However in a bit more complex network configuration when your VLAN interface is 
created on top of bridge that includes “hardware” interface your VLAN interface 
doesn’t support same timestamping capabilities as “hardware” interface, 
obviously:

$ ip -j link show vlan1 | jq '.[] | .link’
“br1”

$ ip -j link show eth1 | jq '.[] | .master'
"br1"

$ ethtool -T vlan1
Time stamping parameters for vlan1:
Capabilities:
software-receive  (SOF_TIMESTAMPING_RX_SOFTWARE)
software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none

Regard,
Zaripov Kamil___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH] Add option to bind raw and UDP sockets to interface

2023-03-10 Thread Richard Cochran
On Fri, Mar 10, 2023 at 01:00:51PM +0200, Zaripov Kamil wrote:
> This patch allows to set interface name in 'iface:bind' format where:
> - 'iface' is network interface that supports PTP
> - 'bind' is network interface to bind socket
> This feature can be useful if you have one physical network interface that
> serves two or more logical local networks separated with VLAN tags. If you
> have to serve PTP clients on both of this local networks you need to bind
> to different interfaces representing different VLANs.
> 
> Most part of this patch just adjusting code where we read configuration
> for interface so we can set different settings for 'eth0:vlan1' and
> 'eth0:vlan2', for example.

Um, unless I'm mistaken, this is unneeded, because you can specify a
VLAN interface just like a normal interface.  In the kernel, the VLAN
interface stacks on top of the physical one and passes the time
stamping APIs through.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH] Add option to bind raw and UDP sockets to interface

2023-03-10 Thread Zaripov Kamil
This patch allows to set interface name in 'iface:bind' format where:
- 'iface' is network interface that supports PTP
- 'bind' is network interface to bind socket
This feature can be useful if you have one physical network interface that
serves two or more logical local networks separated with VLAN tags. If you
have to serve PTP clients on both of this local networks you need to bind
to different interfaces representing different VLANs.

Most part of this patch just adjusting code where we read configuration
for interface so we can set different settings for 'eth0:vlan1' and
'eth0:vlan2', for example.

Signed-off-by: Zaripov Kamil 
---
 .gitignore|  1 +
 clock.c   | 22 +--
 config.c  |  8 ++--
 interface.c   | 34 +++--
 interface.h   | 14 +++
 port.c| 95 ---
 port_private.h|  1 +
 raw.c | 12 --
 udp.c |  8 ++--
 udp6.c| 10 +++--
 unicast_client.c  |  4 +-
 unicast_service.c |  6 +--
 12 files changed, 134 insertions(+), 81 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1e7d1ca..8d3e171 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
 /snmp4lptp
 /timemaster
 /ts2phc
+/tz2alt
diff --git a/clock.c b/clock.c
index 75d7c40..b79fa68 100644
--- a/clock.c
+++ b/clock.c
@@ -1182,14 +1182,14 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
if (interface_tsinfo_valid(iface) &&
!interface_tsmodes_supported(iface, 
required_modes)) {
pr_err("interface '%s' does not support requested 
timestamping mode",
-   interface_name(iface));
+   interface_name_full(iface));
return NULL;
}
}
 
iface = STAILQ_FIRST(>interfaces);
 
-   conf_phc_index = config_get_int(config, interface_name(iface), 
"phc_index");
+   conf_phc_index = config_get_int(config, interface_name_full(iface), 
"phc_index");
 
/* determine PHC Clock index */
if (config_get_int(config, NULL, "free_running")) {
@@ -1232,38 +1232,38 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
 
uds_ifname = config_get_string(config, NULL, "uds_address");
c->uds_rw_if = interface_create(uds_ifname);
-   if (config_set_section_int(config, interface_name(c->uds_rw_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_rw_if),
   "announceReceiptTimeout", 0)) {
return NULL;
}
-   if (config_set_section_int(config, interface_name(c->uds_rw_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_rw_if),
"delay_mechanism", DM_AUTO)) {
return NULL;
}
-   if (config_set_section_int(config, interface_name(c->uds_rw_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_rw_if),
"network_transport", TRANS_UDS)) {
return NULL;
}
-   if (config_set_section_int(config, interface_name(c->uds_rw_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_rw_if),
   "delay_filter_length", 1)) {
return NULL;
}
 
uds_ifname = config_get_string(config, NULL, "uds_ro_address");
c->uds_ro_if = interface_create(uds_ifname);
-   if (config_set_section_int(config, interface_name(c->uds_ro_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_ro_if),
   "announceReceiptTimeout", 0)) {
return NULL;
}
-   if (config_set_section_int(config, interface_name(c->uds_ro_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_ro_if),
   "delay_mechanism", DM_AUTO)) {
return NULL;
}
-   if (config_set_section_int(config, interface_name(c->uds_ro_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_ro_if),
   "network_transport", TRANS_UDS)) {
return NULL;
}
-   if (config_set_section_int(config, interface_name(c->uds_ro_if),
+   if (config_set_section_int(config, interface_name_full(c->uds_ro_if),
   "delay_filter_length", 1)) {
return NULL;
}
@@ -1414,7 +1414,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
/* Create the ports. */
STAILQ_FOREACH(iface, >interfaces, list) {
if (clock_add_port(c, phc_device, phc_index, timestamping, 
iface)) {
-   pr_err("failed to open port %s", interface_name(iface));
+