Skip to content

Socket ether linux step2 #17926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Conversation

devnexen
Copy link
Member

No description provided.

@devnexen devnexen force-pushed the socket_ether_linux_step2 branch 2 times, most recently from e201885 to 1f1f204 Compare February 26, 2025 21:09
@devnexen devnexen marked this pull request as ready for review February 26, 2025 21:46
@devnexen devnexen requested a review from kocsismate as a code owner February 26, 2025 21:46
@devnexen devnexen requested a review from arnaud-lb February 26, 2025 21:46
@devnexen devnexen marked this pull request as draft February 27, 2025 12:16
@devnexen devnexen marked this pull request as ready for review February 27, 2025 21:28
@bukka
Copy link
Member

bukka commented Mar 3, 2025

This has a bit of class design so it should be probably at least posted to internals (it's not like adding a constant or a simple funciton). I agree that there should be some namespacing as well possibly. Definitely not the current names that will easily result in BC break for appliations.

@devnexen devnexen marked this pull request as draft March 7, 2025 19:52
@devnexen devnexen force-pushed the socket_ether_linux_step2 branch 2 times, most recently from 9e8daaa to 8cd42ca Compare March 7, 2025 22:29
@devnexen devnexen marked this pull request as ready for review March 8, 2025 18:14
@devnexen
Copy link
Member Author

ping @arnaud-lb I think I have, at least, addressed the majority of your remarks :).

@devnexen devnexen force-pushed the socket_ether_linux_step2 branch 2 times, most recently from c2fa112 to 3a67b50 Compare March 20, 2025 04:18
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I missed you ping

@devnexen devnexen force-pushed the socket_ether_linux_step2 branch 7 times, most recently from f8cb8fe to d23895d Compare April 13, 2025 13:05
@devnexen devnexen requested a review from arnaud-lb April 13, 2025 13:45
struct ipv6hdr a;
memcpy(&a, payload, sizeof(a));
struct ipv6hdr *ip = &a;
size_t totalip = sizeof(*ip) + ip->payload_len;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not trust ip->payload_len


switch (protocol) {
case ETH_P_IP: {
payload = ((unsigned char *)e + ETH_HLEN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must check that slen >= ETH_HLEN

switch (ip->protocol) {
case IPPROTO_TCP: {
struct tcphdr a;
memcpy(&a, ipdata, sizeof(a));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must check that ipdata + sizeof(tcphdr) < ZSTR_VAL(recv_buf) + slen

}
case IPPROTO_UDP: {
struct udphdr a;
memcpy(&a, ipdata, sizeof(a));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

break;
}
case ETH_P_IPV6: {
payload = ((unsigned char *)e + ETH_HLEN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

switch (ipprotocol) {
case IPPROTO_TCP: {
struct tcphdr a;
memcpy(&a, ipdata, sizeof(a));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too (I think this switch block is the same as in the ETH_P_IP case, and could be extracted to a separate function?)

}
case IPPROTO_UDP: {
struct udphdr a;
memcpy(&a, ipdata, sizeof(a));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

break;
}
case ETH_P_LOOP: {
struct ethhdr *innere = (struct ethhdr *)((unsigned char *)e + ETH_HLEN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

zend_update_property_long(Z_OBJCE_P(szpayload), Z_OBJ_P(szpayload), ZEND_STRL("srcPort"), ntohs(tcp->th_sport));
zend_update_property_long(Z_OBJCE_P(szpayload), Z_OBJ_P(szpayload), ZEND_STRL("dstPort"), ntohs(tcp->th_dport));
zend_update_property_long(Z_OBJCE_P(szpayload), Z_OBJ_P(szpayload), ZEND_STRL("headerSize"), sizeof(*tcp));
zend_update_property_string(Z_OBJCE_P(szpayload), Z_OBJ_P(szpayload), ZEND_STRL("rawPacket"), (char *)ipdata);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use zend_update_property_stringl() here (and in other places), as ipdata is not a null-terminated string

@devnexen devnexen marked this pull request as draft May 19, 2025 11:37
@devnexen devnexen force-pushed the socket_ether_linux_step2 branch from 6b017cf to 83453b9 Compare May 19, 2025 11:37
@devnexen devnexen force-pushed the socket_ether_linux_step2 branch 6 times, most recently from 25916f0 to bcd27d7 Compare June 2, 2025 06:03
@devnexen devnexen marked this pull request as ready for review June 2, 2025 06:32
@devnexen devnexen requested a review from arnaud-lb June 2, 2025 06:33
@devnexen devnexen force-pushed the socket_ether_linux_step2 branch 3 times, most recently from 2bfafbf to 640ee0b Compare June 18, 2025 23:40
@devnexen
Copy link
Member Author

@arnaud-lb I did rerun your comments and pushed changes, please review.

@devnexen devnexen marked this pull request as draft June 21, 2025 06:21
@devnexen devnexen force-pushed the socket_ether_linux_step2 branch from e8e4066 to 3177aed Compare June 21, 2025 21:05
@devnexen devnexen force-pushed the socket_ether_linux_step2 branch from 6a8bff1 to df0befa Compare June 23, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants