Skip to content

Commit

Permalink
ksmbd: fix
Browse files Browse the repository at this point in the history
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Jan 10, 2025
1 parent 8b9c3ec commit fe13cb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
41 changes: 19 additions & 22 deletions transport_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,14 @@ static int create_socket(struct interface *iface)
return ret;
}

bool ksmbd_find_netdev_name_iface_list(char *netdev_name)
struct interface *ksmbd_find_netdev_name_iface_list(char *netdev_name)
{
struct interface *iface;

list_for_each_entry(iface, &iface_list, entry)
if (!strcmp(iface->name, netdev_name))
return true;
return false;
return iface;
return NULL;
}

static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
Expand All @@ -560,22 +560,21 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
struct interface *iface;
int ret;
bool found = false;

switch (event) {
case NETDEV_UP:
if (netdev->priv_flags & IFF_BRIDGE_PORT)
return NOTIFY_OK;

found = ksmbd_find_netdev_name_iface_list(netdev->name);
if (found == true && iface->state == IFACE_STATE_DOWN) {
iface = ksmbd_find_netdev_name_iface_list(netdev->name);
if (iface && iface->state == IFACE_STATE_DOWN) {
ksmbd_debug(CONN, "netdev-up event: netdev(%s) is going up\n",
iface->name);
ret = create_socket(iface);
if (ret)
return NOTIFY_OK;
}
if (found == false && bind_additional_ifaces) {
if (!iface && bind_additional_ifaces) {
iface = alloc_iface(kstrdup(netdev->name, KSMBD_DEFAULT_GFP));
if (!iface)
return NOTIFY_OK;
Expand All @@ -587,21 +586,19 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
}
break;
case NETDEV_DOWN:
list_for_each_entry(iface, &iface_list, entry) {
if (!strcmp(iface->name, netdev->name) &&
iface->state == IFACE_STATE_CONFIGURED) {
ksmbd_debug(CONN, "netdev-down event: netdev(%s) is going down\n",
iface->name);
tcp_stop_kthread(iface->ksmbd_kthread);
iface->ksmbd_kthread = NULL;
mutex_lock(&iface->sock_release_lock);
tcp_destroy_socket(iface->ksmbd_socket);
iface->ksmbd_socket = NULL;
mutex_unlock(&iface->sock_release_lock);

iface->state = IFACE_STATE_DOWN;
break;
}
iface = ksmbd_find_netdev_name_iface_list(netdev->name);
if (iface && iface->state == IFACE_STATE_CONFIGURED) {
ksmbd_debug(CONN, "netdev-down event: netdev(%s) is going down\n",
iface->name);
tcp_stop_kthread(iface->ksmbd_kthread);
iface->ksmbd_kthread = NULL;
mutex_lock(&iface->sock_release_lock);
tcp_destroy_socket(iface->ksmbd_socket);
iface->ksmbd_socket = NULL;
mutex_unlock(&iface->sock_release_lock);

iface->state = IFACE_STATE_DOWN;
break;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion transport_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define __KSMBD_TRANSPORT_TCP_H__

int ksmbd_tcp_set_interfaces(char *ifc_list, int ifc_list_sz);
bool ksmbd_find_netdev_name_iface_list(char *netdev_name);
struct interface *ksmbd_find_netdev_name_iface_list(char *netdev_name);
int ksmbd_tcp_init(void);
void ksmbd_tcp_destroy(void);

Expand Down

0 comments on commit fe13cb2

Please sign in to comment.